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

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit c03f90289c145507ca55de5341d4a8ccc53c8f45
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Tue Nov 21 19:46:28 2023 +0100

    Flush the error stream before to exist the SIS command-line application.
    Otherwise error messages are lost.
---
 endorsed/src/org.apache.sis.console/main/module-info.java      |  2 +-
 .../main/org/apache/sis/console/Command.java                   |  3 ++-
 .../main/org/apache/sis/console/CommandRunner.java             | 10 ++++++++++
 .../main/org/apache/sis/console/package-info.java              |  2 +-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/endorsed/src/org.apache.sis.console/main/module-info.java 
b/endorsed/src/org.apache.sis.console/main/module-info.java
index 15fc19aa76..04b493293f 100644
--- a/endorsed/src/org.apache.sis.console/main/module-info.java
+++ b/endorsed/src/org.apache.sis.console/main/module-info.java
@@ -20,7 +20,7 @@
  * An introduction is available in the <a 
href="https://sis.apache.org/command-line.html";>Apache SIS web site</a>.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   0.3
  */
 module org.apache.sis.console {
diff --git 
a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/Command.java 
b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/Command.java
index 69842f14af..06024bf7fc 100644
--- 
a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/Command.java
+++ 
b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/Command.java
@@ -72,7 +72,7 @@ import org.apache.sis.util.logging.MonolineFormatter;
  * at the Java Virtual Machine startup time. See {@linkplain 
org.apache.sis.console package javadoc} for more information.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.5
  * @since   0.3
  */
 public final class Command {
@@ -278,6 +278,7 @@ public final class Command {
         } catch (Exception e) {
             status = exitCodeFor(e);
         }
+        c.command.flush();
         if (status != 0) {
             System.exit(status);
         }
diff --git 
a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java
 
b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java
index d2c2424916..647a88fd7b 100644
--- 
a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java
+++ 
b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/CommandRunner.java
@@ -347,4 +347,14 @@ abstract class CommandRunner {
      * @throws Exception if an error occurred while executing the sub-command.
      */
     public abstract int run() throws Exception;
+
+    /**
+     * Invoked before to exit the JVM for flushing and pending information to 
the output streams.
+     * The default information flushed {@link #out} and {@link #err} in that 
order.
+     * Subclasses may override if there is more things to flush.
+     */
+    protected void flush() {
+        out.flush();
+        err.flush();
+    }
 }
diff --git 
a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/package-info.java
 
b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/package-info.java
index 778211da37..e5dd6749b0 100644
--- 
a/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/package-info.java
+++ 
b/endorsed/src/org.apache.sis.console/main/org/apache/sis/console/package-info.java
@@ -56,7 +56,7 @@
  * and Management Using JMX Technology</a> page.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.4
+ * @version 1.5
  * @since   0.3
  */
 package org.apache.sis.console;

Reply via email to