Skip to content

Commit

Permalink
Remove unnecessary toString calls in String.format and System.out/err…
Browse files Browse the repository at this point in the history
…or.println calls
  • Loading branch information
stevejagodzinski committed Oct 25, 2021
1 parent 10c38ba commit 201591a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/test/java/HttpEventCollector_JavaLoggingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void errorHandlingInvalidToken() throws Exception {


System.out.println("======print logEx");
System.out.println(logEx.toString());
System.out.println(logEx);
System.out.println("======finish print logEx");
Assert.assertEquals("Invalid token", logEx.get(1).getErrorText());
Assert.assertEquals(4, logEx.get(1).getErrorCode());
Expand Down Expand Up @@ -338,9 +338,9 @@ public void errorHandlingDisabledHttpEventCollectorEndpoint() throws Exception {
Assert.fail("didn't catch errors");
Assert.assertEquals(1, errors.size());

System.out.println(logEx.toString());
System.out.println(logEx);
if (!StringUtils.containsAny(logEx.toString(), "Failed to connect to", "Remote host terminated the handshake", "Connection reset"))
Assert.fail(String.format("Unexpected error message '%s'", logEx.toString()));
Assert.fail(String.format("Unexpected error message '%s'", logEx));
}


Expand Down
4 changes: 2 additions & 2 deletions src/test/java/HttpEventCollector_Log4j2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void errorHandlingInvalidToken() throws Exception {
}

System.out.println("======print logEx");
System.out.println(logEx.toString());
System.out.println(logEx);
System.out.println("======finish print logEx");
Assert.assertEquals("Invalid token", logEx.get(1).getErrorText());
Assert.assertEquals(4, logEx.get(1).getErrorCode());
Expand Down Expand Up @@ -327,7 +327,7 @@ public void errorHandlingDisabledHttpEventCollectorEndpoint() throws Exception {

System.out.println(logEx);
if (!StringUtils.containsAny(logEx.toString(), "Failed to connect to", "Remote host terminated the handshake", "Connection reset"))
Assert.fail(String.format("Unexpected error message '%s'", logEx.toString()));
Assert.fail(String.format("Unexpected error message '%s'", logEx));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/HttpEventCollector_LogbackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void errorHandlingInvalidToken() throws Exception {


System.out.println("======print logEx");
System.out.println(logEx.toString());
System.out.println(logEx);
System.out.println("======finish print logEx");
Assert.assertEquals("Invalid token", logEx.get(1).getErrorText());
Assert.assertEquals(4, logEx.get(1).getErrorCode());
Expand Down Expand Up @@ -317,9 +317,9 @@ public void errorHandlingDisabledHttpEventCollectorEndpoint() throws Exception {
Assert.fail("didn't catch errors");
Assert.assertEquals(1, errors.size());

System.out.println(logEx.toString());
System.out.println(logEx);
if (!StringUtils.containsAny(logEx.toString(), "Failed to connect to", "Remote host terminated the handshake", "Connection reset"))
Assert.fail(String.format("Unexpected error message '%s'", logEx.toString()));
Assert.fail(String.format("Unexpected error message '%s'", logEx));
}

/**
Expand Down

0 comments on commit 201591a

Please sign in to comment.