NullPointerException in the HTTP Example

Trustin Lee tlee at redhat.com
Sat Mar 14 02:09:27 EDT 2009


Hi Richard,

Thanks for reporting the problem.  Actually the problem has been fixed
in trunk.  You might want to download the nightly build for the time
being.

— Trustin Lee, http://gleamynode.net/Y



On Sat, Mar 14, 2009 at 1:39 PM, Richard Jackson
<richard.jackson at gmail.com> wrote:
> Just thought I would let you know that the HTTP Example will throw a
> NullPointerException in the  HttpRequestHandler the line shown in the
> stack trace below is this one:
>
> Map<String, Cookie> cookies =
> cookieDecoder.decode(request.getHeader(HttpHeaders.Names.COOKIE));
>
> This is the stack trace for it. It should be noted that the line
> numbers for HttpRequestHandler will not line up with what is in the
> example but it is the same code I just changed the package name. I'm
> using the example to test some of my other code. (server
> startup/shutdown and configuration)
>
> [Thread-4] DEBUG org.jhserv.jacks.httpservice - HttpManagedService
> registered and started...
> [New I/O server worker #1-1] WARN org.jboss.netty -
> [org.jboss.netty.channel.SimpleChannelHandler] EXCEPTION, please
> implement org.jhserv.jacks.httpservice.server.HttpRequestHandler.exceptionCaught()
> for proper handling.
> java.lang.NullPointerException
>        at org.jboss.netty.handler.codec.http.CookieDecoder.decode(CookieDecoder.java:58)
>        at org.jhserv.jacks.httpservice.server.HttpRequestHandler.writeResponse(HttpRequestHandler.java:138)
>        at org.jhserv.jacks.httpservice.server.HttpRequestHandler.messageReceived(HttpRequestHandler.java:104)
>        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:385)
>        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:401)
>        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:345)
>        at org.jboss.netty.handler.codec.replay.ReplayingDecoder.handleUpstream(ReplayingDecoder.java:308)
>        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:342)
>        at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:329)
>        at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:302)
>        at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:254)
>        at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:171)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:619)
>
> Removing/commenting out this section of the code gets rid of the NPE
>
>        CookieDecoder cookieDecoder = new CookieDecoder();
>        Map<String, Cookie> cookies =
> cookieDecoder.decode(request.getHeader(HttpHeaders.Names.COOKIE));
>        if (!cookies.isEmpty()) {
>            // Reset the cookies if necessary.
>            CookieEncoder cookieEncoder = new CookieEncoder();
>            for (Cookie cookie : cookies.values()) {
>                cookieEncoder.addCookie(cookie);
>            }
>            response.addHeader(HttpHeaders.Names.SET_COOKIE,
> cookieEncoder.encode());
>        }
>
> For what I'm working on I don't need the cookie stuff so no big deal.
> But thought I should let you know.
>
> Richard Jackson
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>




More information about the netty-users mailing list