Skip to content

Fixed: JmsListenerFactory.getInstance starts a second loader thread when two dispatchers are created concurrently (OFBIZ-13777) - #2511

Open
mridulpathak wants to merge 1 commit into
apache:trunkfrom
mridulpathak:OFBIZ-13777
Open

mridulpathak wants to merge 1 commit into
apache:trunkfrom
mridulpathak:OFBIZ-13777

Conversation

@mridulpathak

Copy link
Copy Markdown
Contributor

JmsListenerFactory.getInstance created a factory whose constructor already started the listener loader thread, and only then tried to publish it with compareAndSet. When two dispatchers were created at the same time, the instance that lost the race was discarded but its thread kept loading listeners into the same static maps under a different lock, so the same JMS listener could be created and connected twice, and the extra one was never closed (on a topic, every message ran the service twice). getInstance now builds the factory without starting the thread and starts it only when its compareAndSet succeeds. The public constructor keeps its current behaviour.

JmsListenerFactory.getInstance created a factory whose constructor already started the listener loader thread, and only then tried to publish it with compareAndSet. When two dispatchers were created at the same time, the instance that lost the race was discarded but its thread kept loading listeners into the same static maps, under a different lock, so the same JMS listener could be created and connected twice and the extra one was never closed. getInstance now builds the factory without starting the thread and starts it only when its compareAndSet succeeds. The public constructor still starts the thread as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant