summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNasser Grainawi <nasser@codeaurora.org>2020-11-01 10:50:58 -0700
committerNasser Grainawi <nasser@codeaurora.org>2020-11-01 10:54:01 -0700
commit0e34c23c9d733cf1761e2d288380e606eca9bb32 (patch)
treee2bb0be8b8f41fa526e6c0cdae8018f0ec7ffabb
parent670d1216a41029ef9a003712d29fab13eb2bf201 (diff)
ReplicationTasksStorage: Handle empty task filesv3.3.0-rc6v3.3.0-rc5v3.3.0-rc4
Instead of NPEing if we manage to read a task file that's empty, return an empty Optional. Running the IT tests 1000 times produced this as the only failure (and only once). Change-Id: I3e7392dfb179795348d7f4a207102aa867aed85b
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
index 38a63ab..3947ebc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
@@ -64,7 +64,7 @@ public class ReplicationTasksStorage {
public static class ReplicateRefUpdate {
public static Optional<ReplicateRefUpdate> createOptionally(Path file) {
try {
- return Optional.of(create(file));
+ return Optional.ofNullable(create(file));
} catch (NoSuchFileException e) {
logger.atFine().log("File %s not found while reading task", file);
} catch (IOException e) {