Skip to content

Fix state-matching defect in RouteSegmentedConnPool - #753

Merged
arturobernalg merged 2 commits into
apache:masterfrom
arturobernalg:route-segmented-connpool-state-match
Nov 25, 2026
Merged

arturobernalg merged 2 commits into
apache:masterfrom
arturobernalg:route-segmented-connpool-state-match

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

compatible(needed, have) treated a null requested state as a wildcard, so pollAvailable() would hand a stateless lease the first available entry regardless of its bound state. A connection carrying another user's state (NTLM/Kerberos/TLS client-cert principal) could therefore be reused by a request that presented no credentials at all, silently breaking UserTokenHandler's documented contract that user-specific resources are never shared across users.

StrictConnPool and LaxConnPool already require an exact state match; this aligns RouteSegmentedConnPool (@Experimental, PoolConcurrencyPolicy.OFFLOCK) with that semantics. stateCompatibilityNullMatchesAnything asserted the buggy behavior as intentional; renamed to stateCompatibilityNullOnlyMatchesNull with the assertion inverted. Added two tests: one pinning the fixed behavior directly, one pinning StrictConnPool/LaxConnPool as the reference semantics this change aligns with.

compatible(needed, have) treated a null requested state as a wildcard,
so pollAvailable() would hand a stateless lease the first available
entry regardless of its bound state. A connection carrying another
user's state (NTLM/Kerberos/TLS client-cert principal) could therefore
be reused by a request that presented no credentials at all, silently
breaking UserTokenHandler's documented contract that user-specific
resources are never shared across users.

StrictConnPool and LaxConnPool already require an exact state match;
align RouteSegmentedConnPool (@experimental) with that semantics.

This commit: the fix itself. Test rewrite and new coverage follow in
the next commit.
…overage

stateCompatibilityNullMatchesAnything asserted the buggy behavior as
intentional; renamed to stateCompatibilityNullOnlyMatchesNull and
inverted the assertion. Added statelessLeaseMustNotReuseAnotherUsersStatefulEntry
and strictAndLaxPoolsDoNotReuseAnotherUsersStatefulEntry, the latter
pinning StrictConnPool/LaxConnPool as the reference semantics this
change aligns RouteSegmentedConnPool with.
@arturobernalg
arturobernalg merged commit 4a9d582 into apache:master Nov 25, 2026
12 checks passed
@ok2c ok2c added this to the 5.5.1 milestone Nov 28, 2026
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.

2 participants