This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.5.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 3e01ca0e828ab6b81f457b811e5b836df58f5aae
Author: Andriy Redko <[email protected]>
AuthorDate: Sun Nov 3 09:30:39 2024 -0500

    CXF-9064: AsyncHTTPConduit doesn't close copied wrappedStream on close 
(#2134)
    
    (cherry picked from commit 8f5e9601f72d7781f72557195beaf771da8cf62c)
    (cherry picked from commit c44a56e8ba514298639b1bccae5502069b251363)
    (cherry picked from commit a8b3fcca479d9943d9552b6565a7016fed9cd6b2)
    
    # Conflicts:
    #       
rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/URLConnectionAsyncHTTPConduit.java
    #       
rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/URLConnectionAsyncHTTPConduit.java
---
 .../cxf/transport/http/asyncclient/AsyncHTTPConduit.java      | 11 ++++++-----
 .../cxf/transport/http/asyncclient/hc5/AsyncHTTPConduit.java  | 11 ++++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git 
a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
 
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
index f12043753e..8405a33e82 100755
--- 
a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
+++ 
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
@@ -418,11 +418,12 @@ public class AsyncHTTPConduit extends 
URLConnectionHTTPConduit {
             }
             closed = true;
             if (!chunking && wrappedStream instanceof CachedOutputStream) {
-                CachedOutputStream out = (CachedOutputStream)wrappedStream;
-                this.basicEntity.setContentLength(out.size());
-                wrappedStream = null;
-                handleHeadersTrustCaching();
-                out.writeCacheTo(wrappedStream);
+                try (CachedOutputStream out = 
(CachedOutputStream)wrappedStream) {
+                    this.basicEntity.setContentLength(out.size());
+                    wrappedStream = null;
+                    handleHeadersTrustCaching();
+                    out.writeCacheTo(wrappedStream);
+                }
             }
             super.close();
         }
diff --git 
a/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduit.java
 
b/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduit.java
index a2798c0f82..a8587ec112 100644
--- 
a/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduit.java
+++ 
b/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduit.java
@@ -432,11 +432,12 @@ public class AsyncHTTPConduit extends 
URLConnectionHTTPConduit {
             }
             closed = true;
             if (!chunking && wrappedStream instanceof CachedOutputStream) {
-                CachedOutputStream out = (CachedOutputStream)wrappedStream;
-                this.basicEntity.setContentLength(out.size());
-                wrappedStream = null;
-                handleHeadersTrustCaching();
-                out.writeCacheTo(wrappedStream);
+                try (CachedOutputStream out = 
(CachedOutputStream)wrappedStream) {
+                    this.basicEntity.setContentLength(out.size());
+                    wrappedStream = null;
+                    handleHeadersTrustCaching();
+                    out.writeCacheTo(wrappedStream);
+                }
             }
             super.close();
         }

Reply via email to