Skip to content

Honor Ordered on Spring Boot options customizers - #3246

Open
Quinn-With-Two-Ns wants to merge 2 commits into
mainfrom
fix/temporal-customizer-ordering
Open

Quinn-With-Two-Ns wants to merge 2 commits into
mainfrom
fix/temporal-customizer-ordering

Conversation

@Quinn-With-Two-Ns

@Quinn-With-Two-Ns Quinn-With-Two-Ns commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

Apply TemporalOptionsCustomizer beans using Spring's standard bean ordering, the same ordering used for injected interceptor lists. After filtering out named non-root customizers, sort the remaining bean instances with Spring's AnnotationAwareOrderComparator and bean definition metadata. This supports PriorityOrdered, Ordered, and ordering annotations, including @Order on @Bean methods. Interceptor wiring and namespace selection are unchanged.

Why?

Customizers are injected as a map so Temporal can filter by bean name. Unlike an injected list, that map is not sorted by Spring. Temporal's old comparator ignored Ordered#getOrder() and resolved conflicting order declarations differently from Spring.

Fixes #3244.

Breaking changes?

No API changes. Customizers that previously ran in registration order despite implementing Ordered, or that relied on Temporal's old annotation precedence, may run in a different order. They now follow Spring's standard ordering rules.

Server PR

Not needed.

Validation

  • Verified that the original regression test fails before the fix (20, 10 instead of 10, 20). Added a second regression test that compares actual customizer invocation order with Spring's ordered bean stream for mixed PriorityOrdered, Ordered, and @Order declarations.
  • ./gradlew --offline spotlessApply passed.
  • Full Spring Boot 2 auto-configuration test suite passed (52 passed, 2 skipped).
  • ActivityClientAutoConfigurationTest passed on Spring Boot 3 and 4 using the project's edgeDepsTest variants.

Note

Medium Risk
No API change, but customizers that depended on registration order or Temporal’s old annotation precedence may run in a different order when building client/worker options.

Overview
Spring Boot now runs TemporalOptionsCustomizer beans in the same order as an injected List, instead of map registration order or Temporal’s former comparator.

chooseTemporalCustomizerBeans still filters non-root namespace customizers by bean name, but sorts the remainder with AnnotationAwareOrderComparator and beanOrderSources, which read bean-definition order, factory-method @Order, and target type metadata the way Spring does for list injection. That restores PriorityOrdered vs Ordered semantics and fixes customizers that implement Ordered#getOrder() but were previously ignored.

JavaDoc on TemporalOptionsCustomizer documents this behavior. New auto-configuration tests assert ascending Ordered values and that invocation order matches Spring’s orderedStream() for mixed priority, class, and method ordering.

Reviewed by Cursor Bugbot for commit 520b0b0. Bugbot is set up for automated code reviews on this repo. Configure here.

Use the customizer instance as the fallback order source so Ordered beans run in ascending order without changing annotation precedence.
@Quinn-With-Two-Ns
Quinn-With-Two-Ns requested a review from a team as a code owner December 1, 2026 23:24
Use Spring’s annotation-aware comparator on the filtered customizer instances, with their bean definition metadata as an order source. This keeps namespace filtering intact and matches Spring list ordering when order sources overlap.

This branch has not been deployed

No deployments
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.

Spring Boot ignores Ordered on TemporalOptionsCustomizer beans

2 participants