NullPointerException in the HTTP Example
Richard Jackson
richard.jackson at gmail.com
Sat Mar 14 17:12:58 EDT 2009
I just copied the example code into my own package and commented out
the cookie stuff because I don't need it for what I'm doing right now.
I'm just using it to verify that I have started/shut down my server
correctly. Once I have that done then I will be replacing it any ways
with a servletHandler I will be writing.
Richard
On Sat, Mar 14, 2009 at 1:09 AM, Trustin Lee <tlee at redhat.com> wrote:
> 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
>>
>
> _______________________________________________
> 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