Re: ServletOutputStream#isReady throws ISE
2017-04-12 18:34 GMT+03:00 Mark Thomas : > > On 12/04/17 16:05, Violeta Georgieva wrote: > > > > > Ok > > I'm going to commit a change. > > If you are quick, it will make it in before I tag 9.0.x and 8.5.x. > I committed the changes. Thanks, Violeta > Mark > > > - > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org >
Re: ServletOutputStream#isReady throws ISE
On 12/04/17 16:05, Violeta Georgieva wrote: > Ok > I'm going to commit a change. If you are quick, it will make it in before I tag 9.0.x and 8.5.x. Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
Re: ServletOutputStream#isReady throws ISE
Hi, 2017-04-12 17:44 GMT+03:00 Mark Thomas : > > On 12/04/17 12:22, Violeta Georgieva wrote: > > 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) > > > > > I think that we should not throw ISE but return "false" in such cases. > > > > What do you think? > > Seems reasonable to me. I've checked the EG archives and I can't find > any reference to a discussion that decided otherwise. Ok I'm going to commit a change. Thanks, Violeta > Mark > > - > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org >
Re: ServletOutputStream#isReady throws ISE
On 12/04/17 12:22, Violeta Georgieva wrote: > 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) > I think that we should not throw ISE but return "false" in such cases. > > What do you think? Seems reasonable to me. I've checked the EG archives and I can't find any reference to a discussion that decided otherwise. Mark - To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org
ServletOutputStream#isReady throws ISE
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--