You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sergey Mashkov <se...@jetbrains.com> on 2017/10/09 14:51:26 UTC

UpgradedServletInputStream.read EOF

Hi

Could anybody explain me why UpgradedServletInputStream does fail with
EOFException in non-blocking mode instead of returning -1 ? Where can I
find exact Servlet API specification about this async API behaviour?

java.io.EOFException
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1159)
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1130)
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1067)
    at org.apache.coyote.http11.upgrade.UpgradeServletInputStream.read(UpgradeServletInputStream.java:150)
    at java.io.InputStream.read(InputStream.java:101)
    at io.ktor.servlet.Reader.loop(ServletReader.kt:38)

Re: UpgradedServletInputStream.read EOF

Posted by Mark Thomas <ma...@apache.org>.
On 09/10/17 15:51, Sergey Mashkov wrote:
> Hi
> 
> Could anybody explain me why UpgradedServletInputStream does fail with
> EOFException in non-blocking mode instead of returning -1 ?

I'm not sure why an EOFException is happening. My guess is multiple
calls to read() without calling isReady() between them.

Once an InputStream is in non-blocking mode, every call to read() should
be preceded by a call to isReady(). Only if isReady() returns true
should there be a read. If isReady() returns false you need to wait for
onDataAvailable() or onAllDataRead(). If you try reading before
onDataAvailable() fires you should see an ISE.

> Where can I
> find exact Servlet API specification about this async API behaviour?

Section 3.7 of the Servlet spec + the relevant Javadoc. It is also
possible some of the fine detail was discussed on the EG mailing list.

Mark

> 
> java.io.EOFException
>     at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1159)
>     at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1130)
>     at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1067)
>     at org.apache.coyote.http11.upgrade.UpgradeServletInputStream.read(UpgradeServletInputStream.java:150)
>     at java.io.InputStream.read(InputStream.java:101)
>     at io.ktor.servlet.Reader.loop(ServletReader.kt:38)
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org