Skip to content

ConcurrentModificationException When IntegrationFlow uses gateway #10309

@venkatg-v

Description

@venkatg-v

In what version(s) of Spring Integration are you seeing this issue?

6.5.1

Describe the bug

It appears that MockIntegrationContext.autoStartupCandidates is updated when SpringIntegrationTestExecutionListener#prepareTestInstance is called causing a ConcurrentModificationException. This happens because the method's iteration over AbstractEndpoints triggers GatewayMessageHandler#initialize for any IntegrationFlows with a gateway, which in turn calls MockIntegrationContext#postProcessBeforeInitialization to add a new candidate.

Note: in #10018 the GatewayMessageHandler#start method was updated which indirectly results in MockIntegrationContext#postProcessBeforeInitialization to be called so I did not see this issue in Spring Integration 6.4.x.

To Reproduce

  1. Create an IntegrationFlow where it uses a gateway.
  2. Create a Test with annotations @SpringBootTest and @SpringIntegrationTest.
  3. Run the test and you will see java.util.ConcurrentModificationException from org.springframework.integration.test.context.SpringIntegrationTestExecutionListener#prepareTestInstance

Expected behavior

The test should not run into a ConcurrentModificationException. Prior to #10018 we did not call MockIntegrationContext#postProcessBeforeInitialization when a gateway was found on an IntegrationFlow.

Sample

Sample Project

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions