Hi, I have a question about ServletOutputStream#isReady.
I have the following scenario: - thread A removes the Read/WriteListeners when async timeout/error happens [1], [2] - before receiving AsyncListener#onTimeout/onError, thread B checks whether it is save to perform write invoking ServletOutputStream#isReady. The exception below happens: java.lang.IllegalStateException: It is invalid to call isReady() when the response has not been put into non-blocking mode at org.apache.coyote.Response.isReady(Response.java:635) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13] at org.apache.catalina.connector.OutputBuffer.isReady(OutputBuffer.java:680) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13] at org.apache.catalina.connector.CoyoteOutputStream.isReady(CoyoteOutputStream.java:162) ~[tomcat-embed-core-8.5.13.jar!/:8.5.13] According to javadoc [3] the ServletOutputStream#isReady method does not throw IllegalStateException. "This method can be used to determine if data can be written without blocking." I also checked the specification and there I did not find the expectation in such situation. " boolean isReady(). This method returns true if a write to the ServletOutputStream will succeed, otherwise it will return false. If this method returns true, a write operation can be performed on the ServletOutputStream. If no further data can be written to the ServletOutputStream. then this method will return false till the underlying data is flushed at which point the container will invoke the onWritePossible method of the WriteListener. A subsequent call to this method will return true. " I think that we should not throw ISE but return "false" in such cases. What do you think? Thanks, Violeta [1] https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/core/AsyncContextImpl.java#L385 [2] https://github.com/apache/tomcat/blob/trunk/java/org/apache/coyote/AsyncStateMachine.java#L395 [3] https://docs.oracle.com/javaee/7/api/javax/servlet/ServletOutputStream.html#isReady--