-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#11736 do not rethrow already thrown exception
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
- Loading branch information
Showing
2 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...core/jetty-io/src/test/java/org/eclipse/jetty/io/content/ContentSinkOutputStreamTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.io.content; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
|
||
import org.eclipse.jetty.io.Content; | ||
import org.eclipse.jetty.io.EofException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class ContentSinkOutputStreamTest | ||
{ | ||
@Test | ||
public void testNoDuplicateExceptionThrown() | ||
{ | ||
EofException eofException = new EofException(); | ||
Content.Sink sink = (last, byteBuffer, callback) -> callback.failed(eofException); | ||
|
||
StringWriter stringWriter = new StringWriter(); | ||
try (OutputStream body = new ContentSinkOutputStream(sink)) | ||
{ | ||
try | ||
{ | ||
body.write('a'); | ||
fail("expected IOException in write()"); | ||
} | ||
catch (IOException e) | ||
{ | ||
body.flush(); | ||
fail("expected IOException in flush()"); | ||
} | ||
} | ||
catch (IOException ex) | ||
{ | ||
ex.printStackTrace(new PrintWriter(stringWriter)); | ||
} | ||
assertThat(stringWriter.toString(), not(containsString("CIRCULAR REFERENCE"))); | ||
} | ||
} |