Skip to content

Conversation

@violetagg
Copy link
Member

  • ServletServerHttpResponse.ResponseAsyncListener#onError/onTimeout
    must complete the async operation
  • ServletHttpHandlerAdapter.HandlerResultSubscriber#onComplete must
    check that the async operation is not completed

Issue: SPR-15412

- ServletServerHttpResponse.ResponseAsyncListener#onError/onTimeout must complete the async operation - ServletHttpHandlerAdapter.HandlerResultSubscriber#onComplete must check that the async operation is not completed Issue: SPR-15412
@rstoyanchev
Copy link
Contributor

The change is merged with some minor polish in a follow-up commit. Please have a look, hopefully didn't break anything inadvertently.

What I'm also wondering is whether the issue can occur the other way around. In other words for the onError signal from the ResponseAsyncListener to reach the HandlerResultSubscriber, which also completes the AsyncContext, first.

@violetagg
Copy link
Member Author

What I'm also wondering is whether the issue can occur the other way around. In other words for the onError signal from the ResponseAsyncListener to reach the HandlerResultSubscriber, which also completes the AsyncContext, first.

Yes you are right. I reproduced it with a debugger.

java.lang.IllegalStateException: Calling [asyncComplete()] is not valid for a request with Async state [MUST_COMPLETE]	at org.apache.coyote.AsyncStateMachine.doComplete(AsyncStateMachine.java:304) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13]	at org.apache.coyote.AsyncStateMachine.asyncComplete(AsyncStateMachine.java:289) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13]	at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:373) [tomcat-embed-core-8.5.13.jar!/:8.5.13]	at org.apache.coyote.Request.action(Request.java:391) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13]	at org.apache.catalina.core.AsyncContextImpl.complete(AsyncContextImpl.java:95) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13]	at org.springframework.http.server.reactive.ServletServerHttpResponse$ResponseAsyncListener.onError(ServletServerHttpResponse.java:189) ~[spring-web-5.0.0.BUILD-SNAPSHOT.jar!/:5.0.0.BUILD-SNAPSHOT 

So we need a check also for ServletHttpHandlerAdapter.TIMEOUT_LISTENER.onError/onTimeout (the new code after polishing)

@rstoyanchev
Copy link
Contributor

Okay thanks, I'll combine then HandlerResultSubscriber and TIMEOUT_LISTENER into one so they can share these checks.

@rstoyanchev
Copy link
Contributor

Okay should be fixed now.

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

Labels

None yet

2 participants