commit | 0e34c23c9d733cf1761e2d288380e606eca9bb32 | [log] [tgz] |
---|---|---|
author | Nasser Grainawi <nasser@codeaurora.org> | Sun Nov 01 10:50:58 2020 -0700 |
committer | Nasser Grainawi <nasser@codeaurora.org> | Sun Nov 01 10:54:01 2020 -0700 |
tree | e2bb0be8b8f41fa526e6c0cdae8018f0ec7ffabb | |
parent | 670d1216a41029ef9a003712d29fab13eb2bf201 [diff] |
ReplicationTasksStorage: Handle empty task files 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
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 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) {