You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Leo Galambos <lg...@hq.egothor.org> on 2010/05/06 17:08:45 UTC

Interceptor && ioReactor thread terminated abnormally

Hello,

I cannot decide who is responsible for an exception in the following
example -- me or http-core? Should I always handle the
"getEntity()==null" case in interceptors?

BTW: ResponseGzipUncompress does not check the case as well
http://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java

Thank you,
LG

===
Example:

WARNING: ioReactor thread
org.apache.http.nio.reactor.IOReactorException: I/O dispatch worker
terminated abnormally
    at
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:326)
    at web.NioHttpDownloader$4.run(NioHttpDownloader.java:163)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
    at web.NioHttpDownloader$3.process(NioHttpDownloader.java:137)
    at
org.apache.http.protocol.BasicHttpProcessor.process(BasicHttpProcessor.java:263)
    at
org.apache.http.nio.protocol.AsyncNHttpClientHandler.responseReceived(AsyncNHttpClientHandler.java:307)
    at
web.NioHttpClientHandler.responseReceived(NioHttpClientHandler.java:89)
    at
org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:168)
    at
org.apache.http.impl.nio.DefaultClientIOEventDispatch.inputReady(DefaultClientIOEventDispatch.java:146)
    at
org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:153)
    at
org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:314)
    at
org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:294)
    at
org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:256)
    at
org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:96)
    at
org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:556)
    ... 1 more

NioHttpClientHandler.responseReceived routine is just:
    public void responseReceived(final NHttpClientConnection conn) {
        this.asyncHandler.responseReceived(conn);
    }

and $3.process routine is:

        httpproc.addInterceptor(new HttpResponseInterceptor() {

            public void process(final HttpResponse response, final
HttpContext context) throws HttpException, IOException {
                HttpEntity entity = response.getEntity();
                // line 137:
                Header ceheader = entity.getContentEncoding();
                ....


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Interceptor && ioReactor thread terminated abnormally

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2010-05-06 at 17:08 +0200, Leo Galambos wrote:
> Hello,
> 
> I cannot decide who is responsible for an exception in the following
> example -- me or http-core? Should I always handle the
> "getEntity()==null" case in interceptors?
> 
> BTW: ResponseGzipUncompress does not check the case as well
> http://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/contrib/src/main/java/org/apache/http/contrib/compress/ResponseGzipUncompress.java
> 
> Thank you,
> LG
> 

Leo,

HTTP response messages that do not enclose an entity are rare but
perfectly valid. So, one should always check whether HttpEntity is null
or not. 

Protocol interceptors in the contrib package are meant as reference
material only and are sometimes oversimplified for brevity. But you are
absolutely right, ResponseGzipUncompress not checking HTTP entity for
being non null is wrong.

Does this answer your question?

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org