Skip to content

Commit

Permalink
Merge pull request #4290 from eclipse/jetty-9.4.x-4269-restore-PrintW…
Browse files Browse the repository at this point in the history
…riter-contract

Issue #4269 - Restoring PrintWriter contract on errors
  • Loading branch information
joakime committed Dec 2, 2019
2 parents c9a65c4 + ff7adab commit d99ae19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Expand Up @@ -128,10 +128,13 @@ protected void setError()
private void isOpen() throws IOException
{
if (_ioException != null)
throw new RuntimeIOException(_ioException);
throw _ioException;

if (_isClosed)
throw new EofException("Stream closed");
{
_ioException = new EofException("Stream closed");
throw _ioException;
}
}

@Override
Expand Down
Expand Up @@ -54,7 +54,6 @@
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.io.AbstractEndPoint;
import org.eclipse.jetty.io.ByteArrayEndPoint;
import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
Expand Down Expand Up @@ -711,7 +710,7 @@ public void testStatusCodesNoErrorHandler(int code, String message, String expec
}

@Test
public void testWriteRuntimeIOException() throws Exception
public void testWriteCheckError() throws Exception
{
Response response = getResponse();

Expand All @@ -725,8 +724,8 @@ public void testWriteRuntimeIOException() throws Exception
writer.println("test");
assertTrue(writer.checkError());

RuntimeIOException e = assertThrows(RuntimeIOException.class, () -> writer.println("test"));
assertEquals(cause, e.getCause());
writer.println("test"); // this should not cause an Exception
assertTrue(writer.checkError());
}

@Test
Expand Down

0 comments on commit d99ae19

Please sign in to comment.