LeoWoerteler commented on code in PR #1380:
URL: https://github.com/apache/cxf/pull/1380#discussion_r1292437604
##########
rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java:
##########
@@ -303,19 +303,34 @@ protected OutputStream createOutputStream(Message
message, boolean needToCacheRe
* This class <i>must</i> be static so it doesn't capture a reference to
{@code HttpClientHTTPConduit.this} and
* through that to {@link HttpClientHTTPConduit#client}. Otherwise the
client can never be garbage collected, which
* means that the companion "SelectorManager" thread keeps running
indefinitely (see CXF-8885).
+ * <p>
+ * The {@link HTTPClientPolicy} must be copied here because its property
change listeners can still have hard
+ * references to the {@code HttpClientHTTPConduit}.
*/
private static final class ProxyFactoryProxySelector extends ProxySelector
{
private final ProxyFactory proxyFactory;
- private final HTTPClientPolicy csPolicy;
+ private final HTTPClientPolicy clientPolicy;
ProxyFactoryProxySelector(ProxyFactory proxyFactory, HTTPClientPolicy
csPolicy) {
this.proxyFactory = proxyFactory;
- this.csPolicy = csPolicy;
+ this.clientPolicy = new HTTPClientPolicy();
Review Comment:
@reta I've figured it out, it turns out I mixed up `SoftReference` and
`WeakReference`. Softly referenced objects are only garbage collected as a last
resort before OOM, while weak references objects are ignored completely by the
GC. I've opened PR #1381 as an alternative to this PR, feel free to reject the
one you like less of the two.
--
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]