This is an automated email from the ASF dual-hosted git repository.
mpochatkin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 950b6d40596 IGNITE-28217 Exit REPL when IOException occurs (#7842)
950b6d40596 is described below
commit 950b6d4059647cc64da81a0270095365264e3962
Author: Vadim Pakhnushev <[email protected]>
AuthorDate: Tue Mar 24 06:02:32 2026 +0300
IGNITE-28217 Exit REPL when IOException occurs (#7842)
---
...nHandlers.java => IoErrorExceptionHandler.java} | 31 +++++++++++++++++-----
.../exception/handler/ReplExceptionHandlers.java | 1 +
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IoErrorExceptionHandler.java
similarity index 52%
copy from
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
copy to
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IoErrorExceptionHandler.java
index dc7e398c7a4..d7f00179834 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/IoErrorExceptionHandler.java
@@ -17,21 +17,38 @@
package org.apache.ignite.internal.cli.core.exception.handler;
+import java.io.IOError;
import java.util.function.Consumer;
-import org.apache.ignite.internal.cli.core.exception.ExceptionHandlers;
+import org.apache.ignite.internal.cli.core.exception.ExceptionHandler;
+import org.apache.ignite.internal.cli.core.exception.ExceptionWriter;
/**
- * Collection of exception handlers for REPL.
+ * Exception handler for {@link IOError}.
+ *
+ * <p>JLine throws {@link IOError} wrapping {@link java.io.IOException} when
terminal I/O fails
+ * (e.g., the parent shell process is killed and the PTY becomes broken).
Without this handler, the REPL loop would spin indefinitely
+ * printing "Unknown error" on every iteration.
*/
-public class ReplExceptionHandlers extends ExceptionHandlers {
+class IoErrorExceptionHandler implements ExceptionHandler<IOError> {
+ private final Consumer<Boolean> endAction;
/**
* Constructor.
*
- * @param stop REPL stop action.
+ * @param endAction action to stop the REPL loop.
*/
- public ReplExceptionHandlers(Consumer<Boolean> stop) {
- addExceptionHandler(new EndOfFileExceptionHandler(stop));
- addExceptionHandler(new UserInterruptExceptionHandler());
+ IoErrorExceptionHandler(Consumer<Boolean> endAction) {
+ this.endAction = endAction;
+ }
+
+ @Override
+ public int handle(ExceptionWriter err, IOError e) {
+ endAction.accept(true);
+ return 1;
+ }
+
+ @Override
+ public Class<IOError> applicableException() {
+ return IOError.class;
}
}
diff --git
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
index dc7e398c7a4..2688fea7f0f 100644
---
a/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
+++
b/modules/cli/src/main/java/org/apache/ignite/internal/cli/core/exception/handler/ReplExceptionHandlers.java
@@ -32,6 +32,7 @@ public class ReplExceptionHandlers extends ExceptionHandlers {
*/
public ReplExceptionHandlers(Consumer<Boolean> stop) {
addExceptionHandler(new EndOfFileExceptionHandler(stop));
+ addExceptionHandler(new IoErrorExceptionHandler(stop));
addExceptionHandler(new UserInterruptExceptionHandler());
}
}