diff --git a/ConsoleSession.java b/ConsoleSession.java index 69cb9976..984f139a 100644 --- a/ConsoleSession.java +++ b/ConsoleSession.java @@ -26,7 +26,11 @@ import graql.lang.query.GraqlQuery; import io.grpc.StatusRuntimeException; import jline.console.ConsoleReader; +import jline.console.history.History; import jline.console.history.FileHistory; +import jline.console.history.MemoryHistory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -48,6 +52,7 @@ * A Grakn Console Session that allows a user to interact with the Grakn Server */ public class ConsoleSession implements AutoCloseable { + private static final Logger LOG = LoggerFactory.getLogger(ConsoleSession.class); private static final String COPYRIGHT = "\n" + "Welcome to Grakn Console. You are now in Grakn Wonderland!\n" + @@ -76,7 +81,7 @@ public class ConsoleSession implements AutoCloseable { private final ConsoleReader consoleReader; private final Printer printer = Printer.stringPrinter(true); - private final FileHistory historyFile; + private final History history; private final GraknClient client; private final GraknClient.Session session; @@ -97,10 +102,17 @@ public class ConsoleSession implements AutoCloseable { this.consoleReader.setPrompt(ANSI_PURPLE + session.keyspace().name() + ANSI_RESET + "> "); this.printErr = printErr; - File file = new File(HISTORY_FILE); - file.createNewFile(); - this.historyFile = new FileHistory(file); - this.consoleReader.setHistory(this.historyFile); + History history; + try { + File file = new File(HISTORY_FILE); + file.createNewFile(); + history = new FileHistory(file); + } catch (IOException e) { + LOG.warn("An in-memory history will be used due to exception raised while trying to access history file: ", e.getMessage()); + history = new MemoryHistory(); + } + this.history = history; + this.consoleReader.setHistory(this.history); } void load(Path filePath) throws IOException { @@ -244,7 +256,6 @@ private void rollback() { } /** - * * @return true if a clean took place, false otherwise * @throws IOException */ @@ -280,7 +291,9 @@ public final void close() { session.close(); client.close(); try { - historyFile.flush(); + if (history instanceof FileHistory) { + ((FileHistory) history).flush(); + } } catch (IOException e) { // Print stacktrace to any available stream // nothing more to do here diff --git a/dependencies/graknlabs/dependencies.bzl b/dependencies/graknlabs/dependencies.bzl index f5e7f94d..36a2c4f5 100644 --- a/dependencies/graknlabs/dependencies.bzl +++ b/dependencies/graknlabs/dependencies.bzl @@ -50,7 +50,7 @@ def graknlabs_protocol(): git_repository( name = "graknlabs_protocol", remote = "https://github.com/graknlabs/protocol", - commit = "af2daa4b0ddce19b4668919ecccd059eb282292b", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_protocol + commit = "246139d83ad8d3b5b3f37e2bf26d3b56fad4d8bc", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_protocol ) def graknlabs_client_java():