DATACMNS-1067 - Fix not to call @AfterDomainEventPublication method from collection of entities.
We now make sure the event cleanup method is called on the aggregate root, not on the parameter object directly (as the latter might be a collection. Original pull request: #216.
This commit is contained in:
committed by
Oliver Gierke
parent
2eb830d68f
commit
417fad340b
@@ -44,6 +44,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Christoph Strobl
|
||||
* @author Yuki Yoshida
|
||||
* @since 1.13
|
||||
* @soundtrack Henrik Freischlader Trio - Master Plan (Openness)
|
||||
*/
|
||||
@@ -164,13 +165,14 @@ public class EventPublishingRepositoryProxyPostProcessor implements RepositoryPr
|
||||
}
|
||||
|
||||
for (Object aggregateRoot : asCollection(object)) {
|
||||
for (Object event : asCollection(ReflectionUtils.invokeMethod(publishingMethod, aggregateRoot))) {
|
||||
Collection<Object> events = asCollection(ReflectionUtils.invokeMethod(publishingMethod, aggregateRoot));
|
||||
for (Object event : events) {
|
||||
publisher.publishEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (clearingMethod != null) {
|
||||
ReflectionUtils.invokeMethod(clearingMethod, object);
|
||||
if (clearingMethod != null && !events.isEmpty()) {
|
||||
ReflectionUtils.invokeMethod(clearingMethod, aggregateRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user