Skip to content

Commit

Permalink
Reduce stack utilization by getting rid of outer Stream API call in T…
Browse files Browse the repository at this point in the history
…estTemplateTestDescriptor::execute

Fixes issue junit-team#4020
  • Loading branch information
amaembo committed Sep 25, 2024
1 parent 12e6bae commit c3ed3b3
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext conte
context.getExtensionRegistry());
AtomicInteger invocationIndex = new AtomicInteger();
// @formatter:off
providers.stream()
.flatMap(provider -> provider.provideTestTemplateInvocationContexts(extensionContext))
.map(invocationContext -> createInvocationTestDescriptor(invocationContext, invocationIndex.incrementAndGet()))
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(invocationTestDescriptor -> execute(dynamicTestExecutor, invocationTestDescriptor));
for (TestTemplateInvocationContextProvider provider : providers) {
provider.provideTestTemplateInvocationContexts(extensionContext)
.forEach(invocationContext -> createInvocationTestDescriptor(invocationContext, invocationIndex.incrementAndGet())
.ifPresent(invocationTestDescriptor -> execute(dynamicTestExecutor, invocationTestDescriptor)));
}
// @formatter:on
validateWasAtLeastInvokedOnce(invocationIndex.get(), providers);
return context;
Expand Down

0 comments on commit c3ed3b3

Please sign in to comment.