Skip to content

Preserve async API version resolver order - #37096

Open
Gimini-3 wants to merge 1 commit into
spring-projects:mainfrom
Gimini-3:fix/async-api-version-resolver-order
Open

Preserve async API version resolver order#37096
Gimini-3 wants to merge 1 commit into
spring-projects:mainfrom
Gimini-3:fix/async-api-version-resolver-order

Conversation

@Gimini-3

Copy link
Copy Markdown

This fixes reactive API version resolution so that resolver registration order is honored.

DefaultApiVersionStrategy.resolveApiVersion currently uses flatMap, which subscribes to resolver publishers concurrently. As a result, next() selects the first emitted value instead of the first non-empty resolver in the configured list. A later resolver can therefore win when it completes faster, and an error from an earlier resolver can be cancelled after a later resolver emits.

This change uses concatMap to subscribe to one resolver at a time. That matches the synchronous resolveVersion implementation and the documented first-non-null resolver behavior.

The added tests deterministically verify that:

  • an earlier resolver wins even while a later resolver can emit immediately
  • an error from an earlier resolver is propagated instead of being masked by a later value

The tests use TestPublisher rather than wall-clock delays.

Tests:

  • ./gradlew :spring-webflux:test --tests org.springframework.web.reactive.accept.DefaultApiVersionStrategiesTests
  • ./gradlew :spring-webflux:check

Signed-off-by: Gimin Kim <138752849+Gimini-3@users.noreply.github.com>
@Gimini-3
Gimini-3 marked this pull request as ready for review July 31, 2026 14:56
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants