Skip to content

Commit 6c861ff

Browse files
committed
avoid NPE in unit tests by setting the original stdout/stderr in tearDown
instead of setting it to null
1 parent b3ceb73 commit 6c861ff

File tree

1 file changed

+7
-2
lines changed
  • cf-java-logging-support-log4j2/src/test/java/com/sap/hcp/cf/logging/common

1 file changed

+7
-2
lines changed

cf-java-logging-support-log4j2/src/test/java/com/sap/hcp/cf/logging/common/AbstractTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@ public abstract class AbstractTest {
2020

2121
protected final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
2222
protected final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
23+
private PrintStream stdout;
24+
private PrintStream stderr;
25+
2326
@Before
2427
public void setupStreams() {
28+
stdout = System.out;
29+
stderr = System.err;
2530
System.setOut(new PrintStream(outContent));
2631
System.setErr(new PrintStream(errContent));
2732
}
2833

2934
@After
3035
public void teardownStreams() {
31-
System.setOut(null);
32-
System.setErr(null);
36+
System.setOut(stdout);
37+
System.setErr(stderr);
3338
}
3439
protected String getMessage() {
3540
return getField("msg");

0 commit comments

Comments
 (0)