Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
Unknown
Description
The JAX-RS Client Javadoc states:
Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well as disposal of a Client instance may be a rather expensive operation. It is therefore advised to construct only a small number of Client instances in the application. Client instances must be properly closed before being disposed to avoid leaking resources.
However, in CXF, this is impossible. On every call to target, ClientImpl creates a fresh WebTargetImpl which then (during request) creates a WebClient instance and registers it within its parent. This baseClients collection only grows as long as the shared Client instance exists and is closed and released only when close is called on it, so that sharing causes a memory leak which cannot be prevented in any way.