Resteasy client not closing connection

I have found one scenario where resteasy is not closing the connection. Is there a way around this? I have created my client as:

ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
HttpClient httpClient = new DefaultHttpClient(cm);
ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
T proxiedService = org.jboss.resteasy.client.ProxyFactory.create(clazz, base, executor);

I am calling the following method on the service

Response deleteObject(@PathParam("id") Long id);

And the service is returning

HTTP/1.1 500 Internal Server Error [Content-Length: 0, Server: Jetty(8.1.2.v20120308)]

Any ideas on what I am missing to get the connection to close. Note: for all other response types, the connections are closing.

I know that if I don't return the 500, everything will work well. But should such a scenario accidentally happen, I want my client to be able to handle it, without running out of connections.


I am assuming that the following method belongs on the resteasy client's proxied interface (?):

Response deleteObject(@PathParam("id") Long id);

If so, the problem here is that your method returns the resteasy ClientResponse object (which is the resteasy implementation of the jax-rs Response). When your method returns a ClientResponse, you assume responsibility for releasing the connection.

In your case, you are also relying on the proxy factory, so it may not be possible to release the connection. In that case, you should change the signature of your method to return either void or the type of the object you expect in the HTTP response body:

void deleteObject(@PathParam("id") Long id);

or if you expected the Foo object back:

Foo deleteObject(@PathParam("id") Long id);

See the resteasy Transport Layer documentation for more information.

Need Your Help

Error parsing SVG path log message in Chrome

javascript google-chrome svg

I am trying to implement a simple painting tool in javascript for freehand drawing over SVG. For free hand I am using a polyline while drawing and once the drawing is completed I am trying to make a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.