https://bz.apache.org/bugzilla/show_bug.cgi?id=65780
Bug ID: 65780
Summary: CoyoteOutputStream should never throw
NullPointerException after AsyncContext.complete() is
called
Product: Tomcat 10
Version: 10.0.14
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ------
CoyoteOutputStream extends ServletOutputStream, so according to the
Servlet/OutputStream API Javadoc,
1. The write() method should throw IOException "if the output stream has been
closed", rather than NullPointerException.
2. The isReady() method should return false if "a write to this
ServletOutputStream will" not succeed.
However, CoyoteOutputStream sometimes does throw NullPointerException after
AsyncContext.complete().
In Async Servlet applications, NullPointerException thrown from write() method
might not be propagated to the application's main thread if the write is
invoked asynchronously.
In Async Servlet application, checking isReady() in a while loop is a normal
practice. Although there shouldn't be any operation after
AsyncContext.complete(), sometimes it's hard/tedious to check whether
AsyncContext.complete() is already called concurrently in another thread due to
race condition, before calling isReady() each time.
The issue is found in Embedded Tomcat 10. The issue should also apply to Tomcat
9, but I have not observed it in that version though.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]