Skip to content

Commit

Permalink
Fix null handling
Browse files Browse the repository at this point in the history
Took 5 minutes
  • Loading branch information
Darkyenus committed Jan 30, 2017
1 parent d1b2ce6 commit 673803b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

name := "tproll"

version := "1.2"
version := "1.2.1"

organization := "com.darkyen"

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/darkyen/tproll/util/PrettyPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public static void append(StringBuilder sb, Object item){

public static void append(StringBuilder sb, Object item, int maxArrayElements){
//To use faster overloads
if (item instanceof Boolean) {
if (item == null) {
sb.append((String)null);
} else if (item instanceof Boolean) {
sb.append((boolean)item);
} else if (item instanceof Character) {
sb.append((char)item);
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/unit/LoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public void fullArray() {
assertLogIs(INFO_PREFIX + "I have these banknotes: String\\[100, 200, -560, 1M Zimbabwe \\$\\]");
}

@Test
public void nullArg() {
log.info("Reason: {}", (Object)null);
assertLogIs(INFO_PREFIX + "Reason: null");
}

@SuppressWarnings("serial")
private static final class DummyException extends Exception {
public DummyException(String message) {
Expand Down

0 comments on commit 673803b

Please sign in to comment.