Skip to content

Commit 697aba9

Browse files
authored
Add 'null' check to guard against bad behavior (#64)
Resolves #62
1 parent 5dbec34 commit 697aba9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/nordstrom/automation/junit/RunAnnouncer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static <T> AtomicTest<T> newAtomicTest(Object runner, T identity) {
114114
*/
115115
@SuppressWarnings("unchecked")
116116
static <T> AtomicTest<T> getAtomicTestOf(Object testKey) {
117-
return (AtomicTest<T>) RUNNER_TO_ATOMICTEST.get(testKey);
117+
return (testKey == null) ? null : (AtomicTest<T>) RUNNER_TO_ATOMICTEST.get(testKey);
118118
}
119119

120120
/**
@@ -129,7 +129,9 @@ private static <T> AtomicTest<T> setTestFailure(Failure failure) {
129129
if (atomicTest == null) {
130130
atomicTest = getAtomicTestOf(failure.getDescription());
131131
}
132-
atomicTest.setThrowable(failure.getException());
132+
if (atomicTest != null) {
133+
atomicTest.setThrowable(failure.getException());
134+
}
133135
return atomicTest;
134136
}
135137

@@ -141,6 +143,6 @@ private static <T> AtomicTest<T> setTestFailure(Failure failure) {
141143
* @return {@code true} if the run watcher in question supports the specified atomic test; otherwise {@code false}
142144
*/
143145
private static boolean isSupported(RunWatcher<?> watcher, AtomicTest<?> atomicTest) {
144-
return watcher.supportedType().isInstance(atomicTest.getIdentity());
146+
return (atomicTest == null) ? false : watcher.supportedType().isInstance(atomicTest.getIdentity());
145147
}
146148
}

0 commit comments

Comments
 (0)