From 1240fb6b9a2b1eb7294a260a5f5bb3482d43863f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 2 Jun 2023 23:25:35 +0200 Subject: [PATCH] Consistently publish events from CompletableFuture Closes gh-30578 (cherry picked from commit b738a202338571b897cd64df3cfe34f11308d8a5) --- .../context/event/ApplicationListenerMethodAdapter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index bc7e1f9398..ea959d9fb9 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -274,7 +274,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe handleAsyncError(ex); } else if (event != null) { - publishEvent(event); + publishEvents(event); } }); } @@ -468,6 +468,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) { @@ -481,6 +484,9 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe } + /** + * Reactive Streams Subscriber for publishing follow-up events. + */ private class EventPublicationSubscriber implements Subscriber { @Override