Hello,

it would be kind if you could help me with my question. I want to abort the
communication with the remote server in case I did not get a 200 Status code
back.

Please see my code below:

            HttpResponse response = httpClient.execute(httpGet);

            int status = response.getStatusLine().getStatusCode();

            if ( status != 200) {
                throw new RuntimeException("No valid result");  // IS THIS
VALID?
            }

            HttpEntity httpEntity = response.getEntity();
            if (httpEntity != null) {


Will this lead to "stale" connections if I simply exit my method with a
RuntimeException or do i have to "consume the Content" with the
"consumeContent()" method in every case or alternatively call
InputStream.close()?? But both methods force me to "open" the Result Stream
and then read it, even tough I am not interested in the Content at all.

I would be very thankfull for some tips how this is implemented the
best/simplest but being "safe" to return connections back to the
connection-pool.

Thank you very much
Jens

Reply via email to