reta commented on code in PR #3541:
URL: https://github.com/apache/cxf/pull/3541#discussion_r4189780304


##########
rt/features/logging/src/main/java/org/apache/cxf/ext/logging/LoggingOutputStream.java:
##########
@@ -71,4 +73,60 @@ public void writeCacheTo(StringBuilder out, String 
charsetName, long limit) thro
         super.writeCacheTo(out, charsetName, limit);
         skipFlushingFlowThroughStream = false;
     }
+
+
+    /**
+     * We override the write() methods in order to catch some error that would 
not
+     * close the CachedOutputStream (ex. IOException "Connection reset by 
peer".
+     * Causing ghost or delayed OUT log and possible memory-leak due to 
DelayedCachedOutputStreamCleaner
+     */
+    @Override
+    public void write(byte[] b) throws IOException {
+        try {
+            super.write(b);
+        } catch (RuntimeException | IOException ex) {
+            handleIoException();
+            throw ex;
+        }
+    }
+
+    @Override
+    public void write(byte[] b, int off, int len) throws IOException {
+        try {
+            super.write(b, off, len);
+        } catch (RuntimeException | IOException ex) {
+            handleIoException();
+            throw ex;
+        }
+    }
+
+    @Override
+    public void write(int b) throws IOException {
+        try {
+            super.write(b);
+        } catch (RuntimeException | IOException ex) {
+            handleIoException();
+            throw ex;
+        }
+    }
+
+    @Override
+    public void close() throws IOException {

Review Comment:
   Oh I see, you want to close() to be skipped altogether (not just 
postClose()), it make sense I think, thank you



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to