From 0bbfd4aaad917b218281f628aec5f2cc24cdadf7 Mon Sep 17 00:00:00 2001 From: mpollack Date: Thu, 30 Jan 2014 18:24:55 -0500 Subject: [PATCH] Guard cast of MemoryHistory --- .../java/org/springframework/shell/core/JLineShell.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/shell/core/JLineShell.java b/src/main/java/org/springframework/shell/core/JLineShell.java index 043c3952..edd5b639 100644 --- a/src/main/java/org/springframework/shell/core/JLineShell.java +++ b/src/main/java/org/springframework/shell/core/JLineShell.java @@ -40,6 +40,7 @@ import java.util.logging.Logger; import jline.WindowsTerminal; import jline.console.ConsoleReader; +import jline.console.history.History; import jline.console.history.MemoryHistory; import org.apache.commons.io.input.ReversedLinesFileReader; @@ -127,7 +128,10 @@ public abstract class JLineShell extends AbstractShell implements Shell, Runnabl // reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true))); openFileLogIfPossible(); - ((MemoryHistory) this.reader.getHistory()).setMaxSize(getHistorySize()); + History history = this.reader.getHistory(); + if (history instanceof MemoryHistory) { + ((MemoryHistory)history).setMaxSize(getHistorySize()); + } // Try to build previous command history from the project's log String[] filteredLogEntries = filterLogEntry(); for (String logEntry : filteredLogEntries) {