Skip to content

[Bug] Lack bean name in @ConditionalOnMissingBean for LettuceClientConfigurationBuilderCustomizer #49290

@m-moris

Description

@m-moris

Query/Question

In AzureLettucePasswordlessAutoConfiguration, the azureLettuceClientConfigurationBuilderCustomizer
bean is annotated with @ConditionalOnMissingBean:

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/data/redis/AzureLettucePasswordlessAutoConfiguration.java#L61-L76

Since @ConditionalOnMissingBean without an explicit value or type attribute resolves to the
return type of the method (LettuceClientConfigurationBuilderCustomizer), this bean is skipped
entirely if any other bean of the same type already exists in the application context — even if
that bean serves a completely different purpose.

As a result, when a user defines their own LettuceClientConfigurationBuilderCustomizer (e.g., for
connection pool tuning), the following Azure-specific configurations are silently lost:

  • redisCredentialsProviderFactory(...) — required for passwordless (Azure AD token-based) authentication
  • clientOptions(...protocolVersion(ProtocolVersion.RESP2)...) — required for RESP2 protocol compatibility

This effectively disables passwordless authentication without any warning or error, which can be
extremely difficult to diagnose.

  • If intentional: Could you please document that users must incorporate redisCredentialsProviderFactory
    and ProtocolVersion.RESP2 into their own customizer when they define one?
  • If unintentional: Would it make sense to either remove @ConditionalOnMissingBean entirely,
    or narrow the condition to @ConditionalOnMissingBean(name = "azureLettuceClientConfigurationBuilderCustomizer")
    so that it guards only by bean name rather than by type?

Note: LettuceClientConfigurationBuilderCustomizer is designed by Spring Boot / Spring Data Redis to
support multiple instances coexisting in the same application context. The bean name
azureLettuceClientConfigurationBuilderCustomizer is explicitly set via @Bean(name = "..."),
yet the condition is evaluated by type — making the explicit name effectively meaningless for the
purpose of this guard.

Why is this not a Bug or a Feature Request?

This is raised as a question because the behavior may be intentional — the @ConditionalOnMissingBean
could be a deliberate design choice to allow users to fully take over the Lettuce client configuration.
However, if unintentional, it would qualify as a bug. Clarification from the maintainers is needed
before filing it as a bug report.

Setup (please complete the following information if applicable):

  • OS: (please fill in)
  • IDE: (please fill in)
  • Library/Libraries: com.azure.spring:spring-cloud-azure-autoconfigure (please fill in version)

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required
fields otherwise we will treat the issuer as an incomplete report

  • Query Added
  • Setup information Added

Note: English is not my first language. This was translated with AI assistance — apologies for any awkward phrasing.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.azure-springAll azure-spring related issuesbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No fields configured for Task.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions