8159031: jjs throws NoSuchFileException if ~/.jjs.history does not exist
authorhannesw
Wed, 08 Jun 2016 15:53:22 +0200
changeset 38898 43383182cae3
parent 38897 b92825d7708c
child 38899 b4b3d017b651
8159031: jjs throws NoSuchFileException if ~/.jjs.history does not exist Reviewed-by: sundar, mhaupt
nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java
--- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java	Tue Jun 07 19:13:26 2016 +0530
+++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java	Wed Jun 08 15:53:22 2016 +0200
@@ -59,7 +59,8 @@
         in.setHandleUserInterrupt(true);
         in.setBellEnabled(true);
         in.setCopyPasteDetection(true);
-        in.setHistory(new EditingHistory(in, Files.readAllLines(historyFile.toPath())) {
+        final Iterable<String> existingHistory = historyFile.exists() ? Files.readAllLines(historyFile.toPath()) : null;
+        in.setHistory(new EditingHistory(in, existingHistory) {
             @Override protected boolean isComplete(CharSequence input) {
                 return completer.isComplete(input.toString());
             }