2

Calling Rest service using Jersey Client using Apache Connector provider. My POST, GET and DELETE calls are successful. However, after calling Account DELETE any subsequent calls are hanging.

Here is my code. In the below case second DELETE call is hanging. Any direction on what I might be doing wrong will help..?

 ClientConfig clientConfig = new ClientConfig();
 clientConfig.connectorProvider(new ApacheConnectorProvider());
 Cleint client = ClientBuilder.newClient(clientConfig);

 Response response = client.target("https://hostname/rest")
            .path("account")
            .path(accountId)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .delete();

 response = client.target("https://hostname/rest")
            .path("account")
            .path(accountId)
            .path("user").path(userId)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .delete();
Vividh S V
  • 131
  • 1
  • 7

1 Answers1

4

You need to close your response after calling it.

Response response = client.target("https://hostname/rest")
        .path("account")
        .path(accountId)
        .request(MediaType.APPLICATION_JSON_TYPE)
        .delete();
response.close();
response = client.target("https://hostname/rest")
        .path("account")
        .path(accountId)
        .path("user").path(userId)
        .request(MediaType.APPLICATION_JSON_TYPE)
        .delete();
John Ament
  • 11,595
  • 1
  • 36
  • 45