Skip to content

Commit 160a4ed

Browse files
committed
Replace never occurring null branch with assertion
1 parent 708bb35 commit 160a4ed

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

junit-platform-engine/src/main/java/org/junit/platform/engine/support/store/NamespacedHierarchicalStore.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,9 @@ void run() {
567567
throw throwAsUncheckedException(e);
568568
}
569569
catch (ExecutionException e) {
570-
Throwable t = e.getCause();
571-
if (t == null) {
572-
t = e;
573-
}
574-
UnrecoverableExceptions.rethrowIfUnrecoverable(t);
570+
// non-null guaranteed by FutureTask
571+
var cause = requireNonNull(e.getCause());
572+
UnrecoverableExceptions.rethrowIfUnrecoverable(cause);
575573
return null;
576574
}
577575
}
@@ -586,12 +584,10 @@ Object getOrThrow() {
586584
throw throwAsUncheckedException(e);
587585
}
588586
catch (ExecutionException e) {
589-
Throwable t = e.getCause();
590-
if (t == null) {
591-
t = e;
592-
}
593-
UnrecoverableExceptions.rethrowIfUnrecoverable(t);
594-
throw throwAsUncheckedException(t);
587+
// non-null guaranteed by FutureTask
588+
var cause = requireNonNull(e.getCause());
589+
UnrecoverableExceptions.rethrowIfUnrecoverable(cause);
590+
throw throwAsUncheckedException(cause);
595591
}
596592
}
597593
}

0 commit comments

Comments
 (0)