This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 982797f9dbd0086656ebcea96c842f7e4055ba19 Author: Andriy Redko <[email protected]> AuthorDate: Tue Oct 13 09:58:55 2026 -0400 Improve logging in case of forceable stream closure (#3557) (cherry picked from commit 1933b4b6640066f06ca4f20ffa91e9aac39221f1) --- .../java/org/apache/cxf/ext/logging/LoggingOutputStream.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingOutputStream.java b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingOutputStream.java index ab3a3b072fb..08ba5a05b3f 100644 --- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingOutputStream.java +++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingOutputStream.java @@ -22,10 +22,14 @@ package org.apache.cxf.ext.logging; import java.io.IOException; import java.io.OutputStream; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Logger; +import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.io.CacheAndWriteOutputStream; public class LoggingOutputStream extends CacheAndWriteOutputStream { + private static final Logger LOG = LogUtils.getL7dLogger(LoggingOutputStream.class); + private boolean skipFlushingFlowThroughStream; private final AtomicBoolean closed = new AtomicBoolean(); @@ -90,7 +94,7 @@ public class LoggingOutputStream extends CacheAndWriteOutputStream { @Override public void write(byte[] b) throws IOException { if (closed.get()) { - throw new IOException("The channel has been closed already"); + throw new IOException("The output stream has been closed already"); } try { super.write(b); @@ -103,7 +107,7 @@ public class LoggingOutputStream extends CacheAndWriteOutputStream { @Override public void write(byte[] b, int off, int len) throws IOException { if (closed.get()) { - throw new IOException("The channel has been closed already"); + throw new IOException("The output stream has been closed already"); } try { super.write(b, off, len); @@ -116,7 +120,7 @@ public class LoggingOutputStream extends CacheAndWriteOutputStream { @Override public void write(int b) throws IOException { if (closed.get()) { - throw new IOException("The channel has been closed already"); + throw new IOException("The output stream has been closed already"); } try { super.write(b); @@ -139,6 +143,7 @@ public class LoggingOutputStream extends CacheAndWriteOutputStream { // Close this CachedOutputStream // Write method maybe called more than one time... but we already consume the stream the first time // So additional call to this.close would produce nothing + LOG.warning("Closing the output stream due to unrecoverable exception (while performing write operation)"); this.close(); } catch (Exception suppressed) { if (ex != null) {
