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) {