-
Bug
-
Resolution: Done
-
Major
-
3.6.2.Final
-
None
-
None
Regression seen with resteasy 3.1.4: An exception thrown during chunked transfer is erroneously suppressed by resteasy. Thus the servlet container deems the call successful and writes a valid end-chunk, the client has no chance to see that there was an error. One common usecase would be to detect whether a large download was completed successfully.
Reproducable by e.g.:
@Path("ErrorAfterFlushWithoutBody") @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) public void errorAfterFlushWithoutBody(@Context HttpServletResponse response) throws IOException { response.getOutputStream().flush(); throw new IOException("a strange io error"); } @Test public void testFlushWithoutBody() throws Exception { String data = NetworkClient.readIgnoreException("localhost", service.getPort(), "/ErrorAfterFlushWithoutBody"); Assert.assertTrue(data.startsWith("HTTP/1.1 200 ")); Assert.assertTrue(data.contains("Transfer-Encoding: chunked")); // there must be no end-chunk Assert.assertFalse(data.endsWith("0")); }
It seems this problem was introduced by this change in SynchronousDispatcher:writeException during RESTEASY-1238 since 3.0.23.Final, 3.1.3.Final .
- if (response.isCommitted()) throw new UnhandledException(Messages.MESSAGES.responseIsCommitted(), e); + if (response.isCommitted()) + { + LogMessages.LOGGER.debug(Messages.MESSAGES.responseIsCommitted()); + return; + }
(... Error handling during chunked transfers is a long sore point. Tomcat was broken until early tomcat8: wrote a valid end-chunk on exception although it should terminate the connection without end-chunk. Apache HttpClient until ~2 years ago was also broken, it simply ignored missing end-chunks due to some broken IIS which always omitted end-chunks. Browsers always ignore missing end-chunks because users have no good options on how to deal with it. The Problem was finally fixed in tomcat+httpclient and i am unhappy to see it resurface with resteasy)
- is caused by
-
RESTEASY-1238 Intermittent java.io.IOException: UT010029: Stream is closed in Java EE 7 using provided undertow, resteasy, and jackson
- Closed
- relates to
-
RESTEASY-2444 Merge two duplicated FakeHttpServer
- Resolved