Explicitly reject invalid aggregate event registrations during publishing.
We now detect that the consumption of the events published during a persistence operation has produced new event instances that would go unpublished and raise an explaining exception. Previously such a scenario would've resulted in a ConcurrentModificationException.
We primarily reject such a scenario as handling the additional event would extend our convenience mechanism over the publishing scope a direct 1:1 replacement with ApplicationEventPublisher would've achieved.
Fixes GH-3116.
@ -111,7 +112,7 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@@ -111,7 +112,7 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@ -144,6 +145,9 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@@ -144,6 +145,9 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
privatestaticStringILLEGAL_MODIFCATION="Aggregate's events were modified during event publication. "
+"Make sure event listeners obtain a fresh instance of the aggregate before adding further events. "
+"Additional events found: %s.";
privatefinalClass<?>type;
privatefinalMethodpublishingMethod;
@ -188,7 +192,11 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@@ -188,7 +192,11 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@ -196,10 +204,21 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@@ -196,10 +204,21 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@ -272,23 +291,34 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
@@ -272,23 +291,34 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr