From b2d09f5c6c624df1c9d1bfa05b1c545d196ff6a0 Mon Sep 17 00:00:00 2001 From: Nadeesh TV Date: Fri, 10 Jun 2016 11:11:52 +0000 Subject: [PATCH] 8155581: jshell tool: replace use of Option.get() Reviewed-by: rfield --- .../classes/jdk/internal/jshell/tool/JShellTool.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 9c9ca187c2c..5e7a9371f1b 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -1426,18 +1426,15 @@ public class JShellTool implements MessageHandler { live = false; if (!replayableHistory.isEmpty()) { // Prevent history overflow by calculating what will fit, starting - // with must recent + // with most recent int sepLen = RECORD_SEPARATOR.length(); int length = 0; int first = replayableHistory.size(); while(length < Preferences.MAX_VALUE_LENGTH && --first >= 0) { length += replayableHistory.get(first).length() + sepLen; } - String hist = replayableHistory - .subList(first + 1, replayableHistory.size()) - .stream() - .reduce( (a, b) -> a + RECORD_SEPARATOR + b) - .get(); + String hist = String.join(RECORD_SEPARATOR, + replayableHistory.subList(first + 1, replayableHistory.size())); prefs.put(REPLAY_RESTORE_KEY, hist); } fluffmsg("jshell.msg.goodbye");