This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new eecdb569159 fix: jline history (#15463)
eecdb569159 is described below

commit eecdb56915921c4a897ca7f4ea155fc7ba4a70e3
Author: CritasWang <[email protected]>
AuthorDate: Thu May 8 10:12:12 2025 +0800

    fix: jline history (#15463)
---
 .../src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git 
a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java 
b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java
index ab039e6dfcd..c902598cd3f 100644
--- a/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java
+++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java
@@ -117,6 +117,18 @@ public class JlineUtils {
     org.jline.reader.impl.DefaultParser parser = new 
org.jline.reader.impl.DefaultParser();
     builder.parser(parser);
     LineReader lineReader = builder.build();
+
+    try {
+      // Load the history file, if loading fails, purge the history file.
+      lineReader.getHistory().attach(lineReader);
+      lineReader.getHistory().load();
+    } catch (Exception e) {
+      try {
+        lineReader.getHistory().purge();
+      } catch (Exception ex) {
+        // Ignore
+      }
+    }
     if (OSUtils.IS_WINDOWS) {
       // If enabled cursor remains in begin parenthesis (gitbash).
       lineReader.setVariable(LineReader.BLINK_MATCHING_PAREN, 0);

Reply via email to