You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2021/04/07 22:58:29 UTC

[GitHub] [cxf] reta commented on a change in pull request #771: CXF-8442 Java 16 & CachedOutputStream Fix IOException closed after multiple close() & postClose() calls

reta commented on a change in pull request #771:
URL: https://github.com/apache/cxf/pull/771#discussion_r609123294



##########
File path: core/src/main/java/org/apache/cxf/io/CachedOutputStream.java
##########
@@ -225,7 +225,11 @@ public void close() throws IOException {
             ciphers.clean();
         }
         if (!maybeDeleteTempFile(currentStream)) {
-            postClose();
+            try {

Review comment:
       @Sevyls thank you for the investigation and the consequent suggested fix. I think we should attack the problem from the different angle (as you also mentioned in the ticket):
    - `postClose()` could raise `IOException` so does `close()` and this is legitimate, no need to catch it
    - however, as you found out, `CacheAndWriteOutputStream` may attempt to close the underlying stream many times
   I think the proper solution would be:
    - `CacheAndWriteOutputStream`  should keep track if the `flowThroughStream` has been closed already 
    - `closeFlowthroughStream()` and `postClose()` should set or/and check if the `flowThroughStream` has been closed already and behave appropriately (flush/close or do nothing)
   
   What do you think?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org