You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2025/06/18 14:21:51 UTC
(cxf) 04/07: CXF-9146 Fix MemoryLeak in HttpClientHttpConduit (#2467)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 2c5175b569f140665f832c799e28d5e9aa7cae8a
Author: Eric Giese <er...@googlemail.com>
AuthorDate: Tue Jun 17 19:01:18 2025 +0200
CXF-9146 Fix MemoryLeak in HttpClientHttpConduit (#2467)
* CXF-9146 if the wrappedStream corresponds to pout then it should be nulled as well. this fixes a memoryleak caused when pout is a PipedOutputStream, as the pipe holds a strong reference to the client thread which must be nulled to avoid MemoryLeaks in class like ThreadLocalClientState, which utilizes the same thread as a key for weakhashmap which in turn points to this very outputstream. this means that the thread is both the key and within the value of an entry of the weakhashamp, [...]
* CXF-9146 both the cachedStream and the wrappedOutputStream references are cleared after closing them
(cherry picked from commit 097b0a7c2cfc0743c05e66d92cb7bc988d618495)
(cherry picked from commit 63653f0ed7cd2a2578dfd6cc3cad08323957dd55)
---
core/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java | 1 +
.../http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java | 1 +
2 files changed, 2 insertions(+)
diff --git a/core/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java b/core/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
index 084f624bb6..c962faf2c6 100644
--- a/core/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
+++ b/core/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
@@ -75,6 +75,7 @@ public abstract class AbstractWrappedOutputStream extends OutputStream {
public void close() throws IOException {
if (wrappedStream != null) {
wrappedStream.close();
+ wrappedStream = null;
}
}
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index 8979b52f3a..7b185d5931 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -1421,6 +1421,7 @@ public abstract class HTTPConduit
} finally {
if (cachingForRetransmission && cachedStream != null) {
cachedStream.close();
+ cachedStream = null;
}
}
} catch (HttpRetryException e) {