diff --git a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java index 9df6053524..58cdf96851 100644 --- a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java +++ b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/GerritServer.java @@ -49,6 +49,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -169,22 +170,28 @@ public class GerritServer { } else { site = initSite(cfg); daemonService = Executors.newSingleThreadExecutor(); - daemonService.submit( - new Callable() { - @Override - public Void call() throws Exception { - int rc = - daemon.main( - new String[] { - "-d", site.getPath(), "--headless", "--console-log", "--show-stack-trace", - }); - if (rc != 0) { - System.err.println("Failed to start Gerrit daemon"); - serverStarted.reset(); - } - return null; - } - }); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + daemonService.submit( + new Callable() { + @Override + public Void call() throws Exception { + int rc = + daemon.main( + new String[] { + "-d", + site.getPath(), + "--headless", + "--console-log", + "--show-stack-trace", + }); + if (rc != 0) { + System.err.println("Failed to start Gerrit daemon"); + serverStarted.reset(); + } + return null; + } + }); serverStarted.await(); System.out.println("Gerrit Server Started"); } diff --git a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheFactory.java b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheFactory.java index 393a74ba88..474fa366d8 100644 --- a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheFactory.java +++ b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheFactory.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.eclipse.jgit.lib.Config; @@ -116,7 +117,9 @@ class H2CacheFactory implements PersistentCacheFactory, LifecycleListener { if (executor != null) { for (final H2CacheImpl cache : caches) { executor.execute(cache::start); - cleanup.schedule(() -> cache.prune(cleanup), 30, TimeUnit.SECONDS); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + cleanup.schedule(() -> cache.prune(cleanup), 30, TimeUnit.SECONDS); } } } diff --git a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java index bed6f38ca9..e489257727 100644 --- a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java +++ b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java @@ -46,6 +46,7 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -196,7 +197,9 @@ public class H2CacheImpl extends AbstractLoadingCache implements Per cal.add(Calendar.DAY_OF_MONTH, 1); long delay = cal.getTimeInMillis() - TimeUtil.nowMs(); - service.schedule(() -> prune(service), delay, TimeUnit.MILLISECONDS); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + service.schedule(() -> prune(service), delay, TimeUnit.MILLISECONDS); } static class ValueHolder { diff --git a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java index 3dc6864305..c7d9916f39 100644 --- a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java +++ b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java @@ -40,6 +40,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -116,34 +117,37 @@ public abstract class AbstractLuceneIndex implements Index { .setNameFormat(index + " Commit-%d") .setDaemon(true) .build()); - autoCommitExecutor.scheduleAtFixedRate( - new Runnable() { - @Override - public void run() { - try { - if (autoCommitWriter.hasUncommittedChanges()) { - autoCommitWriter.manualFlush(); - autoCommitWriter.commit(); + @SuppressWarnings("unused") // Error handling within Runnable. + Future possiblyIgnoredError = + autoCommitExecutor.scheduleAtFixedRate( + new Runnable() { + @Override + public void run() { + try { + if (autoCommitWriter.hasUncommittedChanges()) { + autoCommitWriter.manualFlush(); + autoCommitWriter.commit(); + } + } catch (IOException e) { + log.error("Error committing " + index + " Lucene index", e); + } catch (OutOfMemoryError e) { + log.error("Error committing " + index + " Lucene index", e); + try { + autoCommitWriter.close(); + } catch (IOException e2) { + log.error( + "SEVERE: Error closing " + + index + + " Lucene index after OOM;" + + " index may be corrupted.", + e); + } + } } - } catch (IOException e) { - log.error("Error committing " + index + " Lucene index", e); - } catch (OutOfMemoryError e) { - log.error("Error committing " + index + " Lucene index", e); - try { - autoCommitWriter.close(); - } catch (IOException e2) { - log.error( - "SEVERE: Error closing " - + index - + " Lucene index after OOM; index may be corrupted.", - e); - } - } - } - }, - commitPeriod, - commitPeriod, - MILLISECONDS); + }, + commitPeriod, + commitPeriod, + MILLISECONDS); } writer = new TrackingIndexWriter(delegateWriter); searcherManager = new WrappableSearcherManager(writer.getIndexWriter(), true, searcherFactory); diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java index f7f49972d7..3b910bbaa9 100644 --- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java +++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/util/LogFileCompressor.java @@ -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 diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeCleanupRunner.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeCleanupRunner.java index 04899edbb6..429918815d 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeCleanupRunner.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeCleanupRunner.java @@ -25,6 +25,7 @@ import com.google.gerrit.server.util.ManualRequestContext; import com.google.gerrit.server.util.OneOffRequestContext; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +65,11 @@ public class ChangeCleanupRunner implements Runnable { String.format( "Ignoring invalid changeCleanup schedule configuration: %s", scheduleConfig)); } else { - queue.getDefaultQueue().scheduleAtFixedRate(runner, delay, interval, TimeUnit.MILLISECONDS); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + queue + .getDefaultQueue() + .scheduleAtFixedRate(runner, delay, interval, TimeUnit.MILLISECONDS); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java index 2562557f6f..240a3eecdc 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/ChangeInserter.java @@ -70,6 +70,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.transport.ReceiveCommand; @@ -449,7 +450,9 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp { } }; if (requestScopePropagator != null) { - sendEmailExecutor.submit(requestScopePropagator.wrap(sender)); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + sendEmailExecutor.submit(requestScopePropagator.wrap(sender)); } else { sender.run(); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/EmailReviewComments.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/EmailReviewComments.java index 8313b0ac37..392db81cc0 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/EmailReviewComments.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/EmailReviewComments.java @@ -42,6 +42,7 @@ import com.google.inject.ProvisionException; import com.google.inject.assistedinject.Assisted; import java.util.List; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,7 +112,8 @@ public class EmailReviewComments implements Runnable, RequestContext { } void sendAsync() { - sendEmailsExecutor.submit(this); + @SuppressWarnings("unused") + Future possiblyIgnoredError = sendEmailsExecutor.submit(this); } @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/EmailMerge.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/EmailMerge.java index e80bbd8baf..44450f0deb 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/EmailMerge.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/EmailMerge.java @@ -35,6 +35,7 @@ import com.google.inject.Provider; import com.google.inject.ProvisionException; import com.google.inject.assistedinject.Assisted; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,8 @@ public class EmailMerge implements Runnable, RequestContext { } public void sendAsync() { - sendEmailsExecutor.submit(this); + @SuppressWarnings("unused") + Future possiblyIgnoredError = sendEmailsExecutor.submit(this); } @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/GarbageCollectionRunner.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/GarbageCollectionRunner.java index eba5177eaf..08d04ec6cf 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/GarbageCollectionRunner.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/GarbageCollectionRunner.java @@ -22,6 +22,7 @@ import com.google.gerrit.server.config.GcConfig; import com.google.gerrit.server.config.ScheduleConfig; import com.google.gerrit.server.project.ProjectCache; import com.google.inject.Inject; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,9 +53,11 @@ public class GarbageCollectionRunner implements Runnable { } else if (delay < 0 || interval <= 0) { gcLog.warn(String.format("Ignoring invalid gc schedule configuration: %s", scheduleConfig)); } else { - queue - .getDefaultQueue() - .scheduleAtFixedRate(gcRunner, delay, interval, TimeUnit.MILLISECONDS); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + queue + .getDefaultQueue() + .scheduleAtFixedRate(gcRunner, delay, interval, TimeUnit.MILLISECONDS); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java index 8946042768..c1448c136f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergedByPushOp.java @@ -39,6 +39,7 @@ import com.google.inject.assistedinject.AssistedInject; import java.io.IOException; import java.util.Collections; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; @@ -164,27 +165,29 @@ public class MergedByPushOp extends BatchUpdate.Op { if (!correctBranch) { return; } - sendEmailExecutor.submit( - requestScopePropagator.wrap( - new Runnable() { - @Override - public void run() { - try { - MergedSender cm = - mergedSenderFactory.create(ctx.getProject(), psId.getParentKey()); - cm.setFrom(ctx.getAccountId()); - cm.setPatchSet(patchSet, info); - cm.send(); - } catch (Exception e) { - log.error("Cannot send email for submitted patch set " + psId, e); - } - } + @SuppressWarnings("unused") // Runnable already handles errors + Future possiblyIgnoredError = + sendEmailExecutor.submit( + requestScopePropagator.wrap( + new Runnable() { + @Override + public void run() { + try { + MergedSender cm = + mergedSenderFactory.create(ctx.getProject(), psId.getParentKey()); + cm.setFrom(ctx.getAccountId()); + cm.setPatchSet(patchSet, info); + cm.send(); + } catch (Exception e) { + log.error("Cannot send email for submitted patch set " + psId, e); + } + } - @Override - public String toString() { - return "send-email merged"; - } - })); + @Override + public String toString() { + return "send-email merged"; + } + })); changeMerged.fire( change, patchSet, ctx.getAccount(), patchSet.getRevision().get(), ctx.getWhen()); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java index f9832883f9..1206156652 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java @@ -138,6 +138,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.jgit.errors.IncorrectObjectTypeException; @@ -1959,8 +1960,9 @@ public class ReceiveCommits { Change change = notes.getChange(); if (change.getDest().equals(magicBranch.dest)) { logDebug("Found change {} from existing refs.", change.getKey()); - // reindex the change asynchronously - indexer.indexAsync(project.getNameKey(), change.getId()); + // Reindex the change asynchronously, ignoring errors. + @SuppressWarnings("unused") + Future possiblyIgnoredError = indexer.indexAsync(project.getNameKey(), change.getId()); return true; } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/RenameGroupOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/RenameGroupOp.java index 63d8641ca1..ccaaa36a9e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/RenameGroupOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/RenameGroupOp.java @@ -23,6 +23,7 @@ import com.google.inject.assistedinject.Assisted; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.RepositoryNotFoundException; @@ -92,11 +93,12 @@ public class RenameGroupOp extends DefaultQueueOp { } } - // If one or more projects did not update, wait 5 minutes - // and give it another attempt. + // If one or more projects did not update, wait 5 minutes and give it + // another attempt. If it doesn't update after that, give up. if (!retryOn.isEmpty() && !tryingAgain) { tryingAgain = true; - start(5, TimeUnit.MINUTES); + @SuppressWarnings("unused") + Future possiblyIgnoredError = start(5, TimeUnit.MINUTES); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java index bd1f2cd0ad..4d99dd09ff 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReplaceOp.java @@ -61,6 +61,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; @@ -412,7 +413,9 @@ public class ReplaceOp extends BatchUpdate.Op { }; if (requestScopePropagator != null) { - sendEmailExecutor.submit(requestScopePropagator.wrap(sender)); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + sendEmailExecutor.submit(requestScopePropagator.wrap(sender)); } else { sender.run(); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/PutName.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/PutName.java index dbbf0e3855..b78f4a5b9e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/PutName.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/PutName.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.TimeZone; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @Singleton @@ -125,13 +126,15 @@ public class PutName implements RestModifyView { groupCache.evict(group); groupCache.evictAfterRename(old, key); - renameGroupOpFactory - .create( - currentUser.get().newCommitterIdent(new Date(), TimeZone.getDefault()), - group.getGroupUUID(), - old.get(), - newName) - .start(0, TimeUnit.MILLISECONDS); + @SuppressWarnings("unused") + Future possiblyIgnoredError = + renameGroupOpFactory + .create( + currentUser.get().newCommitterIdent(new Date(), TimeZone.getDefault()), + group.getGroupUUID(), + old.get(), + newName) + .start(0, TimeUnit.MILLISECONDS); return groupDetailFactory.create(groupId).call(); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java index a2f2e563d2..a788f8cdd7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java @@ -52,6 +52,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.jgit.lib.Config; import org.slf4j.Logger; @@ -313,7 +314,9 @@ public class ChangeIndexer { private void reindexAfterIndexUpdate(Project.NameKey project, Change.Id id) { if (reindexAfterIndexUpdate) { - reindexIfStale(project, id); + // Don't retry indefinitely; if this fails the change will be stale. + @SuppressWarnings("unused") + Future possiblyIgnoredError = reindexIfStale(project, id); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ReindexAfterUpdate.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ReindexAfterUpdate.java index 24cc537450..2b39d09e28 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ReindexAfterUpdate.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ReindexAfterUpdate.java @@ -39,6 +39,7 @@ import com.google.inject.Provider; import java.io.IOException; import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.Future; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -81,7 +82,9 @@ public class ReindexAfterUpdate implements GitReferenceUpdatedListener { @Override public void onSuccess(List changes) { for (Change c : changes) { - executor.submit(new Index(event, c.getId())); + // Don't retry indefinitely; if this fails changes may be stale. + @SuppressWarnings("unused") + Future possiblyIgnoredError = executor.submit(new Index(event, c.getId())); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailReceiver.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailReceiver.java index 1cabe16da4..bbec992fba 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailReceiver.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/receive/MailReceiver.java @@ -28,6 +28,7 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.Callable; +import java.util.concurrent.Future; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -133,7 +134,8 @@ public abstract class MailReceiver implements LifecycleListener { } return null; }; - workQueue.getDefaultQueue().submit(task); + @SuppressWarnings("unused") + Future possiblyIgnoredError = workQueue.getDefaultQueue().submit(task); } else { // Synchronous processing is used only in tests. try { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheClock.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheClock.java index 00e82c497e..20bc57bfa8 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheClock.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheClock.java @@ -20,6 +20,7 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.inject.Inject; import com.google.inject.Singleton; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.eclipse.jgit.lib.Config; @@ -50,18 +51,17 @@ public class ProjectCacheClock { .setDaemon(true) .setPriority(Thread.MIN_PRIORITY) .build()); - executor.scheduleAtFixedRate( - new Runnable() { - @Override - public void run() { - // This is not exactly thread-safe, but is OK for our use. - // The only thread that writes the volatile is this task. - generation = generation + 1; - } - }, - checkFrequencyMillis, - checkFrequencyMillis, - TimeUnit.MILLISECONDS); + @SuppressWarnings("unused") // Runnable already handles errors + Future possiblyIgnoredError = + executor.scheduleAtFixedRate( + () -> { + // This is not exactly thread-safe, but is OK for our use. The only + // thread that writes the volatile is this task. + generation = generation + 1; + }, + checkFrequencyMillis, + checkFrequencyMillis, + TimeUnit.MILLISECONDS); } else { // Magic generation 0 triggers ProjectState to always // check on each needsRefresh() request we make to it.