Skip to content

Commit 6f86f99

Browse files
authored
Improved performance
Changed implementation to use variant 6 proposed in cucumber#2666 .
1 parent e32379e commit 6f86f99

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

cucumber-core/src/main/java/io/cucumber/core/runner/TestAbortedExceptions.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,18 @@ final class TestAbortedExceptions {
2626

2727
static Predicate<Throwable> createIsTestAbortedExceptionPredicate() {
2828
ClassLoader defaultClassLoader = ClassLoaders.getDefaultClassLoader();
29-
return Arrays.stream(TEST_ABORTED_EXCEPTIONS)
30-
.flatMap(s -> {
29+
return throwable -> Arrays.stream(TEST_ABORTED_EXCEPTIONS)
30+
.anyMatch(s -> {
3131
try {
3232
Class<?> aClass = defaultClassLoader.loadClass(s);
33-
return Stream.of(aClass);
33+
return aClass.isInstance(throwable);
3434
} catch (Throwable t) {
3535
rethrowIfUnrecoverable(t);
3636
log.debug(t,
37-
() -> "Failed to load class" + s + ": will not be supported for aborted executions.");
37+
() -> String.format("Failed to load class %s: will not be supported for aborted executions.", s));
3838
}
39-
return Stream.empty();
40-
})
41-
.map(throwable -> (Predicate<Throwable>) throwable::isInstance)
42-
.reduce(__ -> false, Predicate::or);
39+
return false;
40+
});
4341
}
4442

4543
private TestAbortedExceptions() {

0 commit comments

Comments
 (0)