Skip to content

Commit 37c740d

Browse files
committed
GH-9878: Fix ConcurrentModificationException in SpringIntegrationTestExecutionListener
Fixes: gh-9878 * return new list in MockIntegrationContext.getAutoStartupCandidates() Signed-off-by: Alexander Hain <[email protected]>
1 parent 7993e3c commit 37c740d

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

spring-integration-test/src/main/java/org/springframework/integration/test/context/MockIntegrationContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 the original author or authors.
2+
* Copyright 2017-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.
@@ -111,7 +111,7 @@ public void afterSingletonsInstantiated() {
111111
}
112112

113113
List<AbstractEndpoint> getAutoStartupCandidates() {
114-
return this.autoStartupCandidates;
114+
return new ArrayList<>(this.autoStartupCandidates);
115115
}
116116

117117
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.springframework.integration.test.context;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.integration.config.EnableIntegration;
7+
import org.springframework.integration.dsl.IntegrationFlow;
8+
import org.springframework.integration.dsl.context.IntegrationFlowContext;
9+
import org.springframework.integration.endpoint.AbstractEndpoint;
10+
import org.springframework.integration.gateway.MessagingGatewaySupport;
11+
import org.springframework.test.context.ContextConfiguration;
12+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
13+
14+
@SpringJUnitConfig
15+
@ContextConfiguration(classes = MockIntegrationContextTests.Config.class)
16+
@SpringIntegrationTest
17+
public class MockIntegrationContextTests {
18+
@Test
19+
void springIntegrationTestExecutionListenerShouldNotFailWithConcurrentModificationException() {
20+
}
21+
22+
@Configuration
23+
@EnableIntegration
24+
public static class Config {
25+
@Bean
26+
public AbstractEndpoint registerOnStopEndpoint(IntegrationFlowContext integrationFlowContext) {
27+
return new AbstractEndpoint() {
28+
@Override
29+
protected void doStart() {
30+
MessagingGatewaySupport gateway = new MessagingGatewaySupport() {
31+
};
32+
integrationFlowContext.registration(IntegrationFlow.from(gateway).get()).register();
33+
}
34+
35+
@Override
36+
protected void doStop() {
37+
MessagingGatewaySupport gateway = new MessagingGatewaySupport() {
38+
};
39+
integrationFlowContext.registration(IntegrationFlow.from(gateway).get()).register();
40+
}
41+
};
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)