eclipse-ee4j / eclipse-ee4j/jersey

"Error while closing the output stream in order to commit response"

Open
#4,021 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

I am seeing this ERROR with Jersey 2.27 when client disconnects (times out) prior to the server writing the response.

the exception detail is:

```
06:57:32.384 ERROR o.g.j.s.ServerRuntime$Responder "defExec-0" "Error while closing the output stream in order to commit response."
java.lang.IllegalStateException:Null response object
at o.g.g.s.HttpServletResponseImpl.isCommitted(HttpServletResponseImpl.java:401)[grizzly-http-servlet-2.4.0.jar:2.4.0]
at ^.setContentLength(^:275)[^]
at j.s.ServletResponseWrapper.setContentLength(ServletResponseWrapper.java:126)[javax.servlet-api-4.0.1.jar:4.0.1]
at o.g.j.s.i.ResponseWriter.writeResponseStatusAndHeaders(ResponseWriter.java:146)[jersey-container-servlet-core-2.27.jar]
at o.g.j.s.ServerRuntime$Responder$1.getOutputStream(ServerRuntime.java:652)[jersey-server-2.27.jar]
at o.g.j.m.i.CommittingOutputStream.commitStream(CommittingOutputStream.java:195)[jersey-common-2.27.jar]
at ^.flushBuffer(^:300)[^]
at ^.commit(^:256)[^]
at ^.close(^:271)[^]
at o.g.j.m.i.OutboundMessageContext.close(OutboundMessageContext.java:848)[^]
at o.g.j.s.ContainerResponse.close(ContainerResponse.java:413)[jersey-server-2.27.jar]
at o.g.j.s.ServerRuntime$Responder.writeResponse(ServerRuntime.java:734)[^]
at ^.processResponse(^:395)[^]
at ^.process(^:385)[^]
at o.g.j.s.ServerRuntime$AsyncResponder$3.run(^:884)[^]
at o.g.j.i.Errors$1.call(Errors.java:272)[jersey-common-2.27.jar]
at ^.call(^:268)[^]
at o.g.j.i.Errors.process(^:316)[^]
at ^.process(^:298)[^]
at ^.process(^:268)[^]
at o.g.j.p.i.RequestScope.runInScope(RequestScope.java:289)[^]
at o.g.j.s.ServerRuntime$AsyncResponder.resume(ServerRuntime.java:916)[jersey-server-2.27.jar]
at ^.resume(^:872)[^]
at o.s.z.MyResource.lambda$asyncTimeout$1(MyResource.java:88)[classes/]
at o.s.b.ExecutionContexts$PropagatingRunnable.run(ExecutionContexts.java:519)[classes/]
at j.u.c.Executors$RunnableAdapter.call(Executors.java:511)[na:1.8.0_192]
at j.u.c.FutureTask.run(FutureTask.java:266)[^]
at o.s.c.LifoThreadPoolExecutorSQP$QueuedThread.execute(LifoThreadPoolExecutorSQP.java:617)[classes/]
at ^.run(^:530)[^]
```

This can be reliably reproduced by running the unit test at:

https://github.com/zolyfarkas/jaxrs-spf4j-demo/blob/master/src/test/java/org/spf4j/zhelloworld/MyResourceTest.java#L101

this unit test invokes the endpoint at:

https://github.com/zolyfarkas/jaxrs-spf4j-demo/blob/master/src/main/java/org/spf4j/zhelloworld/MyResource.java#L79

Ideally this situation should generate a clearer/better ERROR (or warning?) if possible?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.