Skip to content

Commit

Permalink
fix NPE in Configuration.toString() (eclipse-archived#3169)
Browse files Browse the repository at this point in the history
fixes eclipse-archived#3167
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
  • Loading branch information
Simon Kaufmann authored and maggu2810 committed Mar 22, 2017
1 parent 4f7ec52 commit 034ba55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,14 @@ class ConfigurationTest {

assertThat configuration.get("intField"), is(equalTo(null))
}

@Test
void 'assert toString handles null values gracefully'() {
def properties = new HashMap([
stringField: null
]);
def configuration = new Configuration(properties)
def res = configuration.toString()
assertThat res.contains("type=?"), is(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public String toString() {
sb.append(", ");
}
sb.append(String.format("{key=%s; type=%s; value=%s}", prop.getKey(),
prop.getValue().getClass().getSimpleName(), prop.getValue()));
prop.getValue() != null ? prop.getValue().getClass().getSimpleName() : "?", prop.getValue()));
}
sb.append("]");
return sb.toString();
Expand Down

0 comments on commit 034ba55

Please sign in to comment.