Skip to content

Commit 7b53452

Browse files
committed
Fix releasePartialSequences value propagation for SequenceSizeReleaseStrategy.
Fixes: spring-projects#10003 Issue Link: spring-projects#10003 Signed-off-by: Jiandong Ma <[email protected]>
1 parent 05ee9ff commit 7b53452

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ public void setMinimumTimeoutForEmptyGroups(long minimumTimeoutForEmptyGroups) {
299299
*/
300300
public void setReleasePartialSequences(boolean releasePartialSequences) {
301301
if (!this.releaseStrategySet && releasePartialSequences) {
302-
setReleaseStrategy(new SequenceSizeReleaseStrategy());
302+
SequenceSizeReleaseStrategy sequenceSizeReleaseStrategy = new SequenceSizeReleaseStrategy();
303+
sequenceSizeReleaseStrategy.setReleasePartialSequences(releasePartialSequences);
304+
setReleaseStrategy(sequenceSizeReleaseStrategy);
303305
}
304306
this.releasePartialSequences = releasePartialSequences;
305307
}
@@ -415,14 +417,6 @@ protected void onInit() {
415417
}
416418
}
417419

418-
if (this.releasePartialSequences) {
419-
Assert.isInstanceOf(SequenceSizeReleaseStrategy.class, this.releaseStrategy, () ->
420-
"Release strategy of type [" + this.releaseStrategy.getClass().getSimpleName() +
421-
"] cannot release partial sequences. Use a SequenceSizeReleaseStrategy instead.");
422-
((SequenceSizeReleaseStrategy) this.releaseStrategy)
423-
.setReleasePartialSequences(this.releasePartialSequences);
424-
}
425-
426420
if (this.evaluationContext == null) {
427421
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
428422
}

spring-integration-core/src/test/java/org/springframework/integration/aggregator/AggregatorTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -152,6 +152,8 @@ public void testAggPerfDefaultPartial() throws InterruptedException, ExecutionEx
152152
store.setMessageGroupFactory(messageGroupFactory);
153153

154154
handler.setMessageStore(store);
155+
handler.setBeanFactory(mock(BeanFactory.class));
156+
handler.afterPropertiesSet();
155157

156158
StopWatch stopwatch = new StopWatch();
157159
stopwatch.start();
@@ -173,7 +175,7 @@ public void testAggPerfDefaultPartial() throws InterruptedException, ExecutionEx
173175

174176
Collection<?> result = resultFuture.get(10, TimeUnit.SECONDS);
175177
assertThat(result).isNotNull();
176-
assertThat(result.size()).isEqualTo(120000);
178+
assertThat(result.size()).isEqualTo(1);
177179
assertThat(stopwatch.getTotalTimeSeconds()).isLessThan(60.0); // actually < 2.0, was many minutes
178180
}
179181

0 commit comments

Comments
 (0)