From c145ba5a07274d13ca3c2cb5c5c8a74b1ec4df91 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Sun, 23 Feb 2025 13:11:04 +0100 Subject: [PATCH] GH-1051 - Only unregister resubmitted event publication in case of errors. Before this commit the code resubmitting incomplete event publications unregistered them independently of whether they succeeded or not. We now only do that for failed submissions as an error here indicates a failure to *submit* the publication. As the execution is likely performed asynchronously, a successful hand-off does not implicate the publication being completely processed. --- .../events/core/DefaultEventPublicationRegistry.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/core/DefaultEventPublicationRegistry.java b/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/core/DefaultEventPublicationRegistry.java index 6b71267e..c4b5e7d5 100644 --- a/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/core/DefaultEventPublicationRegistry.java +++ b/spring-modulith-events/spring-modulith-events-core/src/main/java/org/springframework/modulith/events/core/DefaultEventPublicationRegistry.java @@ -218,12 +218,11 @@ public class DefaultEventPublicationRegistry } catch (Exception o_O) { + inProgress.unregister(it); + if (LOGGER.isInfoEnabled()) { LOGGER.info("Error republishing event publication %s.".formatted(it), o_O); } - - } finally { - inProgress.unregister(it); } }); }