Browse Source

Consistently publish events from CompletableFuture

Closes gh-30578
pull/30619/head
Juergen Hoeller 3 years ago
parent
commit
b738a20233
  1. 8
      spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java

8
spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java

@ -274,7 +274,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe @@ -274,7 +274,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
handleAsyncError(ex);
}
else if (event != null) {
publishEvent(event);
publishEvents(event);
}
});
}
@ -466,6 +466,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe @@ -466,6 +466,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
}
/**
* Inner class to avoid a hard dependency on the Reactive Streams API at runtime.
*/
private class ReactiveResultHandler {
public boolean subscribeToPublisher(Object result) {
@ -479,6 +482,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe @@ -479,6 +482,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
}
/**
* Reactive Streams Subscriber for publishing follow-up events.
*/
private class EventPublicationSubscriber implements Subscriber<Object> {
@Override

Loading…
Cancel
Save