Hi,

I'm using Spring's HttpComponentsHttpInvokerRequestExecutor in my
application, configured with a PoolingHttpClientConnectionManager.

It all works fine, except that when a request is executed, the HTTP
connection that was used is closed after every request.  This is a result
of Spring calling HttpPost.releaseConnection().

Ideally the connections would not be closed, but just released back to the
connection pool.   This is especially important for HTTPS connections and
the overhead of handshakes.

My problem is, when httpPost.releaseConnection() is called, instead of just
releasing the connection back to the pool, it closes it.  If you dig into
the code you can see it ends up calling ConnectionHolder.cancel(), where
ideally it would be calling ConnectionHolder.releaseConnection().

I thought I could override the Spring code to NOT call
HttpPost.releaseConnection(), figuring the connection manager would take
care of releasing the connection itself, which it does, but not in my case
because it is a streaming request (these are HTTP posts with input stream):

>From MainClientExec.java:


            // check for entity, release connection if possible
            final HttpEntity entity = response.getEntity();
            if (entity == null || !entity.isStreaming()) {
                // connection not needed and (assumed to be) in re-usable
state
                connHolder.releaseConnection();
                return new HttpResponseProxy(response, null);
            } else {
                return new HttpResponseProxy(response, connHolder);
            }

So - I don't see a way with the API the way it is to do what I require,
which is release the connection (without closing it) after consuming the
response.

I'm happy to provide more details/context if anyone can help....

thanks,

Reply via email to