You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2025/02/12 12:31:48 UTC
(maven) branch master updated: [MNG-8579] StdOut/StdErr printstream bug (#2108)
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push:
new 59e066ba63 [MNG-8579] StdOut/StdErr printstream bug (#2108)
59e066ba63 is described below
commit 59e066ba639b1b35029cb419193b338d1de714cb
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Wed Feb 12 12:31:43 2025 +0000
[MNG-8579] StdOut/StdErr printstream bug (#2108)
This bug was introduced during CLIng dev, when a
wrong force flush was added to flush body.
---
https://issues.apache.org/jira/browse/MNG-8579
---
.../main/java/org/apache/maven/cling/invoker/LookupInvoker.java | 9 +++++++--
.../main/java/org/apache/maven/logging/LoggingOutputStream.java | 5 -----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
index 0afbb1fbdd..a829ac5607 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintStream;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -346,8 +347,12 @@ protected void doConfigureWithTerminal(C context, Terminal terminal) {
MavenSimpleLogger stderr = (MavenSimpleLogger) context.loggerFactory.getLogger("stderr");
stdout.setLogLevel(LocationAwareLogger.INFO_INT);
stderr.setLogLevel(LocationAwareLogger.INFO_INT);
- System.setOut(new LoggingOutputStream(s -> stdout.info("[stdout] " + s)).printStream());
- System.setErr(new LoggingOutputStream(s -> stderr.warn("[stderr] " + s)).printStream());
+ PrintStream psOut = new LoggingOutputStream(s -> stdout.info("[stdout] " + s)).printStream();
+ context.closeables.add(() -> LoggingOutputStream.forceFlush(psOut));
+ PrintStream psErr = new LoggingOutputStream(s -> stderr.warn("[stderr] " + s)).printStream();
+ context.closeables.add(() -> LoggingOutputStream.forceFlush(psErr));
+ System.setOut(psOut);
+ System.setErr(psErr);
// no need to set them back, this is already handled by MessageUtils.systemUninstall() above
}
}
diff --git a/impl/maven-core/src/main/java/org/apache/maven/logging/LoggingOutputStream.java b/impl/maven-core/src/main/java/org/apache/maven/logging/LoggingOutputStream.java
index c514ec91a9..e20546196f 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/logging/LoggingOutputStream.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/logging/LoggingOutputStream.java
@@ -56,11 +56,6 @@ public void write(int b) throws IOException {
}
}
- @Override
- public void flush() throws IOException {
- forceFlush();
- }
-
public void forceFlush() {
if (buf.size() > 0) {
String line = new String(buf.toByteArray(), 0, buf.size());