Assign unused Future return value to a variable

Error Prone plans to make this pattern into a compile error; this avoids
future breakage.

In some of these cases, it's not obvious that ignoring the return value
is the correct thing to do; the hope is that the construct is ugly
enough to make the author think twice. In many cases though, it's clear
that a locally-created Runnable or Callable already does its own error
handling, so we can leave a comment alongside the ignored return value.

Eventually many of these should be audited again, and we can replace
some of the @SuppressWarnings with Error Prone's @CanIgnoreReturnValue.
That much is left for future cleanup.

Change-Id: Ia989214d85e0d6c387e388a77178e0b5c4bf2498
This commit is contained in:
Dave Borowitz
2017-02-02 15:49:50 -05:00
parent a00f42a52f
commit 9189e67c3d
19 changed files with 160 additions and 103 deletions

View File

@@ -31,6 +31,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,9 +64,12 @@ public class LogFileCompressor implements Runnable {
ZoneId zone = ZoneId.systemDefault();
LocalDate now = LocalDate.now(zone);
long milliSecondsUntil11pm = now.atStartOfDay(zone).plusHours(23).toInstant().toEpochMilli();
queue
.getDefaultQueue()
.scheduleAtFixedRate(compressor, milliSecondsUntil11pm, HOURS.toMillis(24), MILLISECONDS);
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
queue
.getDefaultQueue()
.scheduleAtFixedRate(
compressor, milliSecondsUntil11pm, HOURS.toMillis(24), MILLISECONDS);
}
@Override