0

Is it possible to tell from an AsyncContext, whether it has completed, timed out or still waiting to be completed?

I know it's possible to listen for timeout or complete events, but I'd prefer not to define 4 AsyncListener listener methods just to record this information.

Aivar
  • 6,814
  • 5
  • 46
  • 78

1 Answers1

1

If I am not mistaken Tomcat returns null when AsyncContext.getRequest() is called on timeouted AsyncContext.

I can not confirm this behaviour now, moreover it is not documented, hence should be considered unsafe and not portable.

BTW Tomcat was doing that because it reuses HttpServletRequest and response objects once the request is handled, just like it reuses servlet instances or threads. Sounds like insane optimization for me, but the spec does not forbid that...

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674