Skip to content

Commit 7e6c111

Browse files
committed
GH-484 - Let CompletionRegisteringAdvisor forward EventExternalized event.
1 parent 0eb31ce commit 7e6c111

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/support/CompletionRegisteringAdvisor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
175175
if (result instanceof CompletableFuture<?> future) {
176176

177177
return future
178-
.thenAccept(it -> markCompleted(method, argument))
178+
.thenApply(it -> {
179+
markCompleted(method, argument);
180+
return it;
181+
})
179182
.exceptionallyCompose(it -> {
180183
handleFailure(method, it);
181184
return CompletableFuture.failedFuture(it);

spring-modulith-events/spring-modulith-events-core/src/test/java/org/springframework/modulith/events/support/CompletionRegisteringAdvisorUnitTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ void marksLazilyComputedCompletableFutureAsCompleted() throws Throwable {
8989
verify(registry).markCompleted(any(), any());
9090
}
9191

92+
@Test // GH-484
93+
void exposesResultForCompletableFuture() throws Exception {
94+
95+
CompletableFuture<?> future = createProxyFor(bean).asyncWithResult(false);
96+
97+
assertThat(future.get()).isNotNull();
98+
}
99+
92100
private void assertCompletion(BiConsumer<SomeEventListener, Object> consumer) {
93101
assertCompletion(consumer, true);
94102
}

0 commit comments

Comments
 (0)