Set connection timeouts on ActiveMQ factory to prevent indefinite hangs - #383
Merged
Merged
Conversation
ActiveMQConnectionFactory was created with no timeouts, causing setClientID() → ensureConnectionInfoSent() → syncSendPacket() to block forever when a broker becomes unresponsive. Sets connectResponseTimeout and sendTimeout (60s each) on every factory returned by getConnectionFactory(), ensuring connect() fails with a JMSException instead of hanging indefinitely. Fixes jenkinsci#381 Signed-off-by: Greg Allen <gallen@redhat.com> Signed-off-by: Claude Opus 4.6 <noreply@anthropic.com>
ggallen
force-pushed
the
fix/amq-connection-timeout
branch
from
August 5, 2026 12:48
ee226bc to
a7feabf
Compare
Guard against getConnectionFactory() returning null in connect(), sendMessage(), and waitForMessage() to prevent NPE when credentials are not yet loaded at boot. Broaden subscribe()'s catch to include RuntimeException so unexpected errors don't kill the subscriber thread. Incorporates improvements from PR jenkinsci#382 by @hareldev. Signed-off-by: Greg Allen <gallen@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Greg Allen <gallen@redhat.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
connectResponseTimeout(60s) andsendTimeout(60s) on everyActiveMQConnectionFactoryreturned byActiveMqMessagingProvider.getConnectionFactory()setClientID()→ensureConnectionInfoSent()→syncSendPacket()blocks forever onFutureResponse.getResult()when the broker is unresponsiveconnect()fails cleanly instead of hangingFixes #381
Test plan
connect_deafBroker_failsWithinTimeout— spins up a TCP server that accepts connections but never speaks OpenWire; verifiesconnect()returnsfalsewithin a bounded timegetConnectionFactory_setsTimeouts— verifiesconnectResponseTimeoutandsendTimeoutare set on the returned factory🤖 Generated with Claude Code