Skip to content

Conversation

NipponSunrise
Copy link
Contributor

@NipponSunrise NipponSunrise commented Jul 26, 2025

Previously, the @RetryableTopic.includeNames and @RetryableTopic.excludeNames attributes were not resolved from property placeholders (${...}) or SpEL expressions (#{...}), despite the documentation stating that all String properties support such resolution.

This commit ensures proper resolution via BeanExpressionResolver and BeanFactory, consistent with the behavior of other annotations like @KafkaListener.

@NipponSunrise NipponSunrise force-pushed the fix-resolve-retryabletopic-names branch 2 times, most recently from 93d8ae7 to 1bdfc4b Compare July 26, 2025 05:33
@NipponSunrise NipponSunrise changed the title Fix SpEL/placeholder resolution in @RetryableTopic.include and @RetryableTopic.excludeNames Fix SpEL/placeholder resolution in @RetryableTopic.includeNames and @RetryableTopic.excludeNames Jul 26, 2025
@artembilan
Copy link
Member

despite the documentation stating that all String properties support such resolution.

Can you point us, please, where Spring for Apache Kafka documentation says that?

@NipponSunrise
Copy link
Contributor Author

NipponSunrise commented Jul 28, 2025

Can you point us, please, where Spring for Apache Kafka documentation says that?

Certainly — the Javadoc of @RetryableTopic includes the statement:

All String properties can be resolved from property placeholders ${...} or SpEL expressions #{...}.

While includeNames and excludeNames are technically String[] rather than String, it’s a reasonable and common expectation that this applies to all string-valued attributes — including arrays. This interpretation is also consistent with how similar annotations behave, such as @KafkaListener, where array properties like topics support both property placeholders and SpEL expressions on a per-element basis.

Enabling resolution here improves consistency with @KafkaListener, reduces potential surprises, and allows for cleaner externalization of retryable or non-retryable exception lists.

@artembilan
Copy link
Member

Thank you for explanation and contribution!

will be merged once PR build is green.

Looking forward for more!

Previously, the `includeNames` and `excludeNames` attributes of
`@RetryableTopic` were not processed through the configured
`BeanExpressionResolver` and `BeanExpressionContext`.

This change ensures proper resolution from property placeholders
`(${...})` and SpEL expressions `(#{...})`, consistent with the
documentation and behavior of similar annotations like `@KafkaListener`.

Signed-off-by: Dimitri Tugo <[email protected]>
auto-merge was automatically disabled July 28, 2025 17:37

Head branch was pushed to by a user without write access

@NipponSunrise NipponSunrise force-pushed the fix-resolve-retryabletopic-names branch from 1bdfc4b to 66f151f Compare July 28, 2025 17:37
@NipponSunrise
Copy link
Contributor Author

The pull request build failed due to a formatting issue — specifically, a } else if { on the same line.

I've corrected the formatting accordingly.

@artembilan artembilan merged commit d4925d6 into spring-projects:main Jul 28, 2025
3 checks passed
spring-builds pushed a commit that referenced this pull request Jul 28, 2025
Fixes: #4016

Previously, the `includeNames` and `excludeNames` attributes of
`@RetryableTopic` were not processed through the configured
`BeanExpressionResolver` and `BeanExpressionContext`.

This change ensures proper resolution from property placeholders
`(${...})` and SpEL expressions `(#{...})`, consistent with the
documentation and behavior of similar annotations like `@KafkaListener`.

Signed-off-by: Dimitri Tugo <[email protected]>

[[email protected]: Improve comint message]

The Javadoc of the `@RetryableTopic` includes the statement:

>  All String properties can be resolved from property placeholders `${...}` or SpEL expressions `#{...}`.

While `includeNames` and `excludeNames` are technically `String[]` rather than `String`, it’s a reasonable and common expectation that this applies to all string-valued attributes — including arrays.
This interpretation is also consistent with how similar annotations behave, such as `@KafkaListener`, where array properties like topics support both property placeholders and SpEL expressions on a per-element basis.

Enabling resolution here improves consistency with `@KafkaListener`, reduces potential surprises, and allows for cleaner externalization of retryable or non-retryable exception lists.

Signed-off-by: Artem Bilan <[email protected]>
(cherry picked from commit d4925d6)
@NipponSunrise NipponSunrise deleted the fix-resolve-retryabletopic-names branch July 28, 2025 19:11
@artembilan
Copy link
Member

Thank you, @NipponSunrise , for contribution; looking forward for more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants