Christian Habermehl created CXF-8902:
----------------------------------------
Summary: Resource Leak at HttpClientHTTPConduit leads to
OutOfMemoryError
Key: CXF-8902
URL: https://issues.apache.org/jira/browse/CXF-8902
Project: CXF
Issue Type: Bug
Components: Services
Affects Versions: 4.0.2
Environment: Windows 10
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment JBR-17.0.5+1-653.14-jcef (build 17.0.5+1-b653.14)
OpenJDK 64-Bit Server VM JBR-17.0.5+1-653.14-jcef (build 17.0.5+1-b653.14,
mixed mode)
Debian
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)
Reporter: Christian Habermehl
Hello,
I use the [BingAds SDK|https://github.com/BingAds/BingAds-Java-SDK]. This SDK
uses CXF to communicate with the Bing servers. After they upgraded CXF from
3.4.2 to 4.0.2 I run into OutOfMemoryErrors that actually are
OutOfThreadsErrors:
{{java.lang.OutOfMemoryError: unable to create native thread: possibly out of
memory or process/resource limits reached}}
The reason for the error is, that HttpClientHTTPConduit sets up a
HttpClientImpl for each service call:
{code:java}
at
jdk.internal.net.http.HttpClientImpl$SelectorManager.<init>(HttpClientImpl.java:715)
at jdk.internal.net.http.HttpClientImpl.<init>(HttpClientImpl.java:325)
at jdk.internal.net.http.HttpClientImpl.create(HttpClientImpl.java:270)
at
jdk.internal.net.http.HttpClientBuilderImpl.build(HttpClientBuilderImpl.java:135)
at
org.apache.cxf.transport.http.HttpClientHTTPConduit.setupConnection(HttpClientHTTPConduit.java:231)
at
org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:529)
at
org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:47)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:528)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:439)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:354)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:312)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
at jdk.proxy2.$Proxy100.getAccount(Unknown Source:-1)
{code}
Each time a HttpClientImpl is build, a HttpClientImpl$SelectorManager thread is
created. in my case this led to more than 6000 threads and in the end to the
OutOfMemoryError.
Could you please either return URLConnectionHTTPConduit by default in
HTTPTransportFactory#getConduit or try to re-use the HttpClient or shut the
client down when it's not used anymore?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)