Skip to content

[RESTEASY-3675] ServerDrivenNegotiation does not weigh the matching language more than a null language - #4943

Merged
jamezp merged 1 commit into
resteasy:mainfrom
jamezp:RESTEASY-3675-language-matching
Jul 31, 2026
Merged

jamezp merged 1 commit into
resteasy:mainfrom
jamezp:RESTEASY-3675-language-matching

Conversation

@jamezp

@jamezp jamezp commented Jul 30, 2026

Copy link
Copy Markdown
Member

Also ensure that the language order is honored.

Move the VariantSelectionTest method into the ServerDrivenNegotiationTest and delete the VariantSelectionTest. There is no reason for it to be in the unit-tests when it can be tested in reasteasy-core.

https://redhat.atlassian.net/browse/RESTEASY-3675

@theashiot This is a simplified version of #4929. I did add some more tests though. I just saw a simpler way to do this when I was reviewing :) What you did wasn't really wrong, but it looped the requestedLanguages which could end up being a hot call path.

@jamezp
jamezp requested a review from a team as a code owner July 30, 2026 00:24
@jamezp
jamezp force-pushed the RESTEASY-3675-language-matching branch 3 times, most recently from fdc80f1 to 5b5cb80 Compare July 30, 2026 21:41
…erride bug

Rewrite applyLanguage() for readability without changing the matching
algorithm: rename variables to match RFC terminology (range, variantLanguage,
rangeQuality), use local accumulators instead of mid-loop mutation, add
RFC-citing Javadoc. Clean up getBestMatch() and isBetterOption() by removing
dead commented-out code and adding Javadoc documenting the tiebreaker
hierarchy.

Fix a bug where a wildcard (*) in Accept-Language would override an explicit
q=0 exclusion. For example, "Accept-Language: *, en;q=0" would incorrectly
match variant "en" via the wildcard instead of honoring the exclusion. The
wildcard fallback now only activates when no explicit range matched at all,
or when the only match is a reverse-prefix BASE_LANGUAGE match with q=0.

Add Javadoc to all test methods citing the RFC rule each verifies, and add
three new edge-case tests: RESTEASY-3675 reproduction, multiple base-language
quality selection, and EXACT_COUNTRY precision verification.

https://redhat.atlassian.net/browse/RESTEASY-3675

Signed-off-by: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: James R. Perkins <[email protected]>
@jamezp
jamezp force-pushed the RESTEASY-3675-language-matching branch from 5b5cb80 to 44bc773 Compare July 31, 2026 00:05
@jamezp
jamezp merged commit 76c419e into resteasy:main Jul 31, 2026
11 of 12 checks passed
@jamezp
jamezp deleted the RESTEASY-3675-language-matching branch July 31, 2026 15:07
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.

1 participant