Skip to content

Fix intermittent ConcurrentModificationException (#92) #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sbraconnier
Copy link
Contributor

@sbraconnier sbraconnier commented May 17, 2025

Fix Intermittent ConcurrentModificationException using getMergedConnectorMessage (#92)

@jonbartels
Copy link
Contributor

@sbraconnier - I see what the change does and I see how it could prevent a concurrent modification exception.

Can you link to an issue or discussion or other info about why or when the issue happens?

@sbraconnier
Copy link
Contributor Author

sbraconnier commented May 21, 2025

@jonbartels Sorry I only added the reference in the title. I updated the PR description to link the original issue.

Copy link
Member

@tonygermano tonygermano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may not actually fix the issue. I can't find any indication that this method would be called concurrently from two threads. The stack traces from the two nextgen issues don't have mirth versions on them, but they indicate that the problem occurs on one of these two lines (the line numbers shifted in mirth 4.4.0):

responseMap.putAll(connectorMessage.getResponseMap());
channelMap.putAll(connectorMessage.getChannelMap());

The map being modified concurrently is the argument to the putAll method. Since this method doesn't update that map, that means there is probably another thread that isn't trying to call this same method, but is instead updating the responseMap or channelMap for the same connectorMessage while this method is trying to read it.

@sbraconnier
Copy link
Contributor Author

Hmm you're right. I think it would be nice to let the synchronized block since the method is building the mergedConnectorMessage field and it will ensured that 2 threads won't initialized it concurrently. I'll take a look at the putAll calls.

@tonygermano
Copy link
Member

My guess without digging into it too much is that a destination queue thread is updating either the responseMap or the connectorMap while the post-processor is trying to build the mergedConnectorMessage.

It may be that just setting a couple retry attempts within this method if a ConcurrentModificationException is thrown would take care of it since this is pretty rare, and that wouldn't introduce the performance penalties associated with synchronization between threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants