Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE at InternalNioOutputBuffer.addToBB() in Tomcat 7 #874

Closed
masoncj opened this issue Jan 31, 2013 · 2 comments
Closed

NPE at InternalNioOutputBuffer.addToBB() in Tomcat 7 #874

masoncj opened this issue Jan 31, 2013 · 2 comments

Comments

@masoncj
Copy link

masoncj commented Jan 31, 2013

When writing a response from a serializer using tomcat 7.0.32 in a long polling async servlet 3.0 setup, I see the follow exception fairly frequently (but not every time). I came across this post which suggests it might either be a synchronization problem or a async request that has already terminated. This is with atmosphere 1.0.x at rev ac04315.

The code is basically:

resource.setSerializer(new Serializer() {
            @Override
            public void write(OutputStream os, Object message) throws IOException {
                    String serialized = jackson.serializeToJson(message);
                    os.write(serialized);
                    os.flush();
             }
});

Should I:

  • not be calling flush? Am I ensured the data I write gets back to the client without the flush?
  • be synchronizing this somehow? How?
java.lang.NullPointerException
    at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:210)
    at org.apache.coyote.http11.InternalNioOutputBuffer.commit(InternalNioOutputBuffer.java:202)
    at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:765)
    at org.apache.coyote.Response.action(Response.java:174)
    at org.apache.coyote.Response.sendHeaders(Response.java:354)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:330)
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:306)
    at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101)
    at org.codehaus.jackson.impl.Utf8Generator.flush(Utf8Generator.java:1091)
    at org.codehaus.jackson.map.ObjectWriter.writeValue(ObjectWriter.java:328)
    at com.thetus.platforms.savanna.components.job.service.JobServiceRestController$1.write(JobServiceRestController.java:131)
    at org.atmosphere.handler.AbstractReflectorAtmosphereHandler.onStateChange(AbstractReflectorAtmosphereHandler.java:101)
    at org.atmosphere.cpr.DefaultBroadcaster.invokeOnStateChange(DefaultBroadcaster.java:1012)
    at org.atmosphere.cpr.DefaultBroadcaster.executeAsyncWrite(DefaultBroadcaster.java:936)
    at org.atmosphere.cpr.DefaultBroadcaster$3.run(DefaultBroadcaster.java:583)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    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:680)
@jfarcand
Copy link
Member

jfarcand commented Feb 1, 2013

Salut, I suspect the connection has already been resumed and the second call to that resource is causing this issue. The exception will be logged but your application should still work IMO. Is it the case?

@jfarcand
Copy link
Member

I don't think that is cause issue. Just let Atmosphere recover itself from that exception (the message will be cached). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants