eclipse-ee4j / eclipse-ee4j/jersey
Jersey client not releasing connection to HttpClientConnectionManager when using with Proxy
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
We have configure JerseyClient as below and using to make http call
```java
ClientConfig restClientConfig = new ClientConfig();
restClientConfig.connectorProvider(new ApacheConnectorProvider())
.property("jersey.config.apache.client.connectionManager", connectionManager)
.property("jersey.config.client.connectTimeout", Integer.valueOf(connectionTimeout))
.property("jersey.config.client.readTimeout", Integer.valueOf(requestTimeout))
.property("jersey.config.client.proxy.uri","http://:");
javax.ws.rs.client.Client jerseyClient = ClientBuilder.newClient(clientConfig);
WebTarget target = jerseyClient.target();
Response response = target.request().get();
String finalResponse = response.readEntity(String.class);
PoolingHttpClientConnectionManager connectionManager = (PoolingHttpClientConnectionManager) jerseyClient.getConfiguration().getProperty("jersey.config.apache.client.connectionManager");
System.out.println(" Connection Stats: {}", connectionManager.getTotalStats());
```
If i call this piece of code multiple times i am seeing the leased Connection count increasing by 1.
Connection Stats: [leased: 1; pending: 0; available: 4; max: 100]
Connection Stats: [leased: 2; pending: 0; available: 4; max: 100]
Connection Stats: [leased: 3; pending: 0; available: 4; max: 100]
We are using same without proxy and not having any issues.
As per documentation, readEntity should close the connection. We tried explicitly using response.close() as well but it doesn't work and i still see count increasing.
Can someone please check if this is an issue with the jerseyClient itself or there is something wrong i am doing here?
Contributor guide
Assessment
This issue has not been assessed yet.