[jboss-jira] [JBoss JIRA] (WFLY-4561) Servlet Nonblocking I/O Suppressed InputStream Closed Error

Stuart Douglas (JIRA) issues at jboss.org
Mon Apr 27 19:11:52 EDT 2015


    [ https://issues.jboss.org/browse/WFLY-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13063034#comment-13063034 ] 

Stuart Douglas commented on WFLY-4561:
--------------------------------------

I don't really think that this is an error. You called close(), and the stream has closed. In general it is only an error condition if the container has closed the stream, not the user. 

> Servlet Nonblocking I/O Suppressed InputStream Closed Error
> -----------------------------------------------------------
>
>                 Key: WFLY-4561
>                 URL: https://issues.jboss.org/browse/WFLY-4561
>             Project: WildFly
>          Issue Type: Feature Request
>          Components: Web (Undertow)
>    Affects Versions: 8.2.0.Final
>            Reporter: Mark S
>            Assignee: Stuart Douglas
>         Attachments: AsyncIOServletTest.java
>
>
> Created a Nonblocking I/O Servlet by following JEE Tutorial example here:
> https://docs.oracle.com/javaee/7/tutorial/servlets013.htm
> Due to my Eclipse Development Environment giving me the warning "Potential resource leak: 'input' may not be closed", I made a mistake by wrapping the following line with a try-with-resources statement.
> {code}
> final ServletInputStream input = request.getInputStream();
> {code}
> Unfortunately, no exception was thrown to indicate that the connection was already closed before processing was attempted, where I believe there should have been.
> --
> I have added the relevant source code to reproduce my situation.  Please see attached code.
> In the attached source, I added an AsyncListener to monitor the life cycle.
> h4. Case 1
> Client Request:
> {code}
> curl -X POST -H "Content-Type: application/x-www-form-urlencoded" --data '{"records":[{"key":"key1","value":"SGVsbG8gV29ybGQ="}]}' "http://localhost:8080/webapp/test/test"; echo
> {code}
> The handleRequestAsPerJeeTutorialWithInputStreamIssue method will give the following output:
> {code}
> 2015-04-27 10:57:20,337 (INFO ) [] AsyncIOServletTest(37): doPost(..)
> 2015-04-27 10:57:50,345 (INFO ) [] AsyncIOServletTest$1(55): onTimeout called: javax.servlet.AsyncEvent at 24865a17
> 2015-04-27 10:57:50,359 (INFO ) [] AsyncIOServletTest$1(48): onComplete called: javax.servlet.AsyncEvent at 54ff11f3
> {code}
> Client Response:
> {code}
> <html><head><title>Error</title></head><body>Internal Server Error</body></html>
> {code}
> h4. Case 2
> Client Request:
> {code}
> curl -X POST -H "Content-Type: application/x-www-form-urlencoded" --data '{"records":[{"key":"key1","value":"SGVsbG8gV29ybGQ="}]}' "http://localhost:8080/webapp/test/test"; echo
> {code}
> The handleRequestAsPerJeeTutorial method will give the following output:
> {code}
> 2015-04-27 10:56:32,111 (INFO ) [] AsyncIOServletTest(37): doPost(..)
> 2015-04-27 10:56:32,114 (INFO ) [] AsyncIOServletTest(84): handleRequestAsPerJeeTutorial(..)
> 2015-04-27 10:56:32,121 (INFO ) [] AsyncIOServletTest$2(97): onDataAvailable()
> 2015-04-27 10:56:32,121 (INFO ) [] AsyncIOServletTest$2(115): onAllDataRead()
> 2015-04-27 10:56:32,125 (INFO ) [] AsyncIOServletTest$1(48): onComplete called: javax.servlet.AsyncEvent at 3746c9ed
> {code}
> Client Response:
> {code}
> ...the response...
> {code}
> ----
> It is my opinion that a closed InputStream should cause an exception of some sort.  And in this case at minimum, I think that the AsyncListener's onError should be called.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the jboss-jira mailing list