[jboss-jira] [JBoss JIRA] (WFLY-4561) Servlet Nonblocking I/O Suppressed InputStream Closed Error
Mark S (JIRA)
issues at jboss.org
Thu Nov 24 11:08:00 EST 2016
[ https://issues.jboss.org/browse/WFLY-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark S closed WFLY-4561.
------------------------
> 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
(v7.2.3#72005)
More information about the jboss-jira
mailing list