Skip to content

Add @ConditionalOnMissingBean to grpcRequestScope for clarity and configurability#1168

Open
yizhao1998 wants to merge 1 commit intogrpc-ecosystem:masterfrom
yizhao1998:master
Open

Add @ConditionalOnMissingBean to grpcRequestScope for clarity and configurability#1168
yizhao1998 wants to merge 1 commit intogrpc-ecosystem:masterfrom
yizhao1998:master

Conversation

@yizhao1998
Copy link
Copy Markdown

This PR adds the @ConditionalOnMissingBean annotation to the grpcRequestScope bean definition in GrpcServerAutoConfiguration.

Why this change?

  • GrpcRequestScope is already annotated with @Component, meaning it can be registered through component scanning
  • While Spring does not register duplicate beans by default, adding @ConditionalOnMissingBean makes it explicit that this bean is only created if no other GrpcRequestScope instance exists.
  • This improves code clarity and aligns with Spring Boot's best practices for auto-configuration.
  • It ensures better compatibility in cases where GrpcRequestScope might be customized, proxied, or overridden in user applications.

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