GH-483 - Let CompletionRegisteringAdvisor forward EventExternalized event.

This commit is contained in:
Oliver Drotbohm
2024-01-21 17:56:53 +01:00
parent 6770526cac
commit c5f73e675d
2 changed files with 12 additions and 1 deletions

View File

@@ -175,7 +175,10 @@ public class CompletionRegisteringAdvisor extends AbstractPointcutAdvisor {
if (result instanceof CompletableFuture<?> future) {
return future
.thenAccept(it -> markCompleted(method, argument))
.thenApply(it -> {
markCompleted(method, argument);
return it;
})
.exceptionallyCompose(it -> {
handleFailure(method, it);
return CompletableFuture.failedFuture(it);

View File

@@ -89,6 +89,14 @@ class CompletionRegisteringAdvisorUnitTests {
verify(registry).markCompleted(any(), any());
}
@Test // GH-483
void exposesResultForCompletableFuture() throws Exception {
CompletableFuture<?> future = createProxyFor(bean).asyncWithResult(false);
assertThat(future.get()).isNotNull();
}
private void assertCompletion(BiConsumer<SomeEventListener, Object> consumer) {
assertCompletion(consumer, true);
}