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

holgerf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/main by this push:
     new 99c81bc0bc fix(shell): enable autoFlush on console PrintStream (#2267) 
(#2518)
99c81bc0bc is described below

commit 99c81bc0bc7a67b69e1575ee869877d8609cbd37
Author: JB Onofré <[email protected]>
AuthorDate: Tue Apr 14 18:08:20 2026 +0200

    fix(shell): enable autoFlush on console PrintStream (#2267) (#2518)
    
    System.out.print() without a newline was not displayed immediately on
    the Karaf console because the PrintStream wrapping the terminal output
    was created without autoFlush. Enable autoFlush on the local console
    and SSH command PrintStreams, consistent with ShellFactoryImpl.
---
 .../org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java   | 2 +-
 shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
index 440e05afea..3cf7b175b5 100644
--- 
a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
+++ 
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/LocalConsoleManager.java
@@ -77,7 +77,7 @@ public class LocalConsoleManager {
         final Subject subject = createLocalKarafSubject();    
         this.session = JaasHelper.doAs(subject, (PrivilegedAction<Session>) () 
-> {
             String encoding = getEncoding();
-            PrintStream pout = new PrintStream(terminal.output()) {
+            PrintStream pout = new PrintStream(terminal.output(), true, 
Charset.forName(encoding)) {
                 @Override
                 public void close() {
                     // do nothing
diff --git 
a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java 
b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
index 39d0adcd19..0023522ed4 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
@@ -100,7 +100,7 @@ public class ShellCommand implements Command {
         commandThread = Thread.currentThread();
         int exitStatus = 0;
         try {
-            session = sessionFactory.create(in, new PrintStream(out), new 
PrintStream(err));
+            session = sessionFactory.create(in, new PrintStream(out, true), 
new PrintStream(err, true));
             for (Map.Entry<String,String> e : env.getEnv().entrySet()) {
                 session.put(e.getKey(), e.getValue());
             }

Reply via email to