reta commented on code in PR #3541:
URL: https://github.com/apache/cxf/pull/3541#discussion_r4189016085
##########
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:
Could we please do this in postClose() (as in
https://github.com/apache/cxf/pull/3536, it is guaranteed to be called on
close):
```
@Override
protected void postClose() throws IOException {
if (closed.compareAndSet(false, true)) {
getFlowThroughStream().close();
}
}
```
--
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]