summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@verizonmedia.com>2019-09-12 14:56:50 +0200
committerHåkon Hallingstad <hakon@verizonmedia.com>2019-09-12 14:56:50 +0200
commita426ebdb3d1694f84962bb62ebad2573de5f00b0 (patch)
tree950120667bf1fcb5560ea9a732e0758fa5563c85 /node-admin
parent880aa954e780ca7223d5e17b19c085c689ba9f7a (diff)
Simplify statement
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java9
1 files changed, 2 insertions, 7 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java
index dff95efe80d..112197101b4 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/Editor.java
@@ -14,6 +14,7 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Logger;
+import static com.yahoo.vespa.hosted.node.admin.task.util.file.IOExceptionUtil.ifExists;
import static com.yahoo.yolean.Exceptions.uncheck;
/**
@@ -39,13 +40,7 @@ public class Editor {
*/
public Editor(Path path, LineEditor editor) {
this(path.toString(),
- () -> {
- try {
- return Files.readAllLines(path, ENCODING);
- } catch (IOException e) {
- return List.of();
- }
- },
+ () -> ifExists(() -> Files.readAllLines(path, ENCODING)).orElseGet(List::of),
(newLines) -> uncheck(() -> Files.write(path, newLines, ENCODING)),
editor);
}