diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AggregatorEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AggregatorEndpoint.java index 110242618e..f2b618e24f 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AggregatorEndpoint.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AggregatorEndpoint.java @@ -22,7 +22,6 @@ import java.util.concurrent.ScheduledExecutorService; import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageBuilder; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; /** * An {@link AbstractMessageBarrierEndpoint} that waits for a complete @@ -33,8 +32,8 @@ import org.springframework.util.CollectionUtils; * the 'sequenceSize' property of the header. Alternatively, a * custom implementation of the {@link CompletionStrategy} may be provided. *

- * All considerations regarding timeout and grouping by - * 'correlationId' from {@link AbstractMessageBarrierEndpoint} apply + * All considerations regarding timeout and grouping by ' + * correlationId' from {@link AbstractMessageBarrierEndpoint} apply * here as well. * * @author Mark Fisher @@ -46,7 +45,6 @@ public class AggregatorEndpoint extends AbstractMessageBarrierEndpoint { private volatile CompletionStrategy completionStrategy = new SequenceSizeCompletionStrategy(); - /** * Create an endpoint that delegates to the provided Aggregator to combine a * group of messages into a single message. The executor will be used for @@ -63,7 +61,6 @@ public class AggregatorEndpoint extends AbstractMessageBarrierEndpoint { this(aggregator, null); } - /** * Strategy to determine whether the group of messages is complete. */ @@ -79,18 +76,14 @@ public class AggregatorEndpoint extends AbstractMessageBarrierEndpoint { protected boolean isBarrierRemovable(Object correlationId, List> releasedMessages) { return releasedMessages != null && releasedMessages.size() > 0; } - + protected Message[] processReleasedMessages(Object correlationId, List> messages) { - if (CollectionUtils.isEmpty(messages)) { - if (logger.isDebugEnabled()) { - logger.debug("no messages to aggregate"); - } + Message result = aggregator.aggregate(messages); + if (result == null) { return new Message[0]; } - Message result = aggregator.aggregate(messages); if (result.getHeaders().getCorrelationId() == null) { - result = MessageBuilder.fromMessage(result) - .setCorrelationId(correlationId).build(); + result = MessageBuilder.fromMessage(result).setCorrelationId(correlationId).build(); } return new Message[] { result }; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java index 9c15dd211d..2532362823 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java @@ -22,6 +22,7 @@ import java.util.List; import org.springframework.integration.handler.MessageListMethodAdapter; import org.springframework.integration.message.GenericMessage; import org.springframework.integration.message.Message; +import org.springframework.util.CollectionUtils; /** * Aggregator adapter for methods annotated with {@link org.springframework.integration.annotation.Aggregator @Aggregator} @@ -43,6 +44,9 @@ public class MethodInvokingAggregator extends MessageListMethodAdapter implement public Message aggregate(List> messages) { + if (CollectionUtils.isEmpty(messages)) { + return null; + } Object returnedValue = this.executeMethod(messages); if (returnedValue == null) { return null;