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 2018/04/24 18:37:42 UTC

[GitHub] dkulp commented on issue #409: CXF-7710: ClientImpl is memory-leak prone

dkulp commented on issue #409: CXF-7710: ClientImpl is memory-leak prone
URL: https://github.com/apache/cxf/pull/409#issuecomment-384036673
 
 
   Nothing about this change will actually work.   Changing to a WeakHashMap<String, ....> and using a "new String(...)" for the key will result in nothing actually holding onto the key and the context could be garbage collected immediately.    The test case you added (requestContextIsGarbageCollected) shows the exact problem.  Two calls to getRequestContext() on the same thread should return the same context.    It's very common to do:
   ```
   client.getRequestContext().put("A", aValue);
   client.getRequestContext().put("B", bValue);
   client.getRequestContext().put("C", cValue);
   ```
   and that NEEDS to work.    If something triggers a GC between there, values will get lost.
   
   As part of CXF-7591, we made sure the  getResponseContext().clear() will work so that users can explicitly clear the context when done with it to avoid this problem.   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services