This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 8f5e9601f7 CXF-9064: AsyncHTTPConduit doesn't close copied
wrappedStream on close (#2134)
8f5e9601f7 is described below
commit 8f5e9601f72d7781f72557195beaf771da8cf62c
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)
---
.../cxf/transport/http/asyncclient/AsyncHTTPConduit.java | 11 ++++++-----
.../http/asyncclient/URLConnectionAsyncHTTPConduit.java | 11 ++++++-----
.../cxf/transport/http/asyncclient/hc5/AsyncHTTPConduit.java | 11 ++++++-----
.../http/asyncclient/hc5/URLConnectionAsyncHTTPConduit.java | 11 ++++++-----
4 files changed, 24 insertions(+), 20 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 c3eb240191..3cb93af102 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
@@ -416,11 +416,12 @@ public class AsyncHTTPConduit extends
HttpClientHTTPConduit {
}
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-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/URLConnectionAsyncHTTPConduit.java
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/URLConnectionAsyncHTTPConduit.java
index 9244db36ad..e7b280811f 100755
---
a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/URLConnectionAsyncHTTPConduit.java
+++
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/URLConnectionAsyncHTTPConduit.java
@@ -416,11 +416,12 @@ public class URLConnectionAsyncHTTPConduit 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 3372ae4343..689341c4a5 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
@@ -430,11 +430,12 @@ public class AsyncHTTPConduit extends
HttpClientHTTPConduit {
}
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/URLConnectionAsyncHTTPConduit.java
b/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/URLConnectionAsyncHTTPConduit.java
index d8e70f1ff2..81010856e5 100644
---
a/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/URLConnectionAsyncHTTPConduit.java
+++
b/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/URLConnectionAsyncHTTPConduit.java
@@ -432,11 +432,12 @@ public class URLConnectionAsyncHTTPConduit 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();
}