Fix NoFileException during spinSubmit()
If shouldCompleteOngoing() encounters a NoFileException, then it means
that work is being done and this thread doesn't need to do any, so we
can return false.
Change-Id: Ibfd236431fce961fb7d0680c0675c631e0623646
Release-Notes: Fixes bug persisting events in busy multi-primary clusters
diff --git a/src/main/java/com/googlesource/gerrit/plugins/events/fsstore/UpdatableFileValue.java b/src/main/java/com/googlesource/gerrit/plugins/events/fsstore/UpdatableFileValue.java
index 67d51b0..0f7d3b5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/events/fsstore/UpdatableFileValue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/events/fsstore/UpdatableFileValue.java
@@ -16,6 +16,7 @@
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
@@ -290,7 +291,11 @@
// Maximum delay incurred due to a server crash.
FileTime expiry = Fs.getFileTimeAgo(10, TimeUnit.SECONDS);
- return Nfs.isAllEntriesOlderThan(paths.update, expiry);
+ try {
+ return Nfs.isAllEntriesOlderThan(paths.update, expiry);
+ } catch (NoSuchFileException e) {
+ return false;
+ }
}
protected abstract UniqueUpdate<T> createUniqueUpdate(String uuid, boolean ours, long maxTries)