Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrpcAdviceIsPresentCondition breaks beans loading priority #513

Closed
Yaroslav-Kovalchyk-Imprivata opened this issue Mar 22, 2021 · 1 comment · Fixed by #515
Closed

GrpcAdviceIsPresentCondition breaks beans loading priority #513

Yaroslav-Kovalchyk-Imprivata opened this issue Mar 22, 2021 · 1 comment · Fixed by #515
Assignees
Labels
bug Something does not work as expected
Milestone

Comments

@Yaroslav-Kovalchyk-Imprivata
Copy link

I've implemented exception handling class and annotated it with @GrpcAdvice annotation. In another library it is declared an aspect for all methods annotated by @GrpcExceptionHandler annotation, but the aspect is not get applied because there is no way to initialize another configuration before net.devh.boot.grpc.server.autoconfigure.GrpcAdviceAutoConfiguration.
Source of the issue is the way how GrpcAdviceIsPresentCondition is implemented:

public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
final ConfigurableListableBeanFactory safeBeanFactory =
requireNonNull(context.getBeanFactory(), "ConfigurableListableBeanFactory is null");
return !safeBeanFactory.getBeansWithAnnotation(GrpcAdvice.class).isEmpty();
}
call of the method getBeansWithAnnotation() forces initialization of GrpcAdviceAutoConfiguration on bean definitions loading stage and disregards any declared priority.

The fix for the issue would be a usage of getBeanNamesForAnnotation() instead of getBeansWithAnnotation()

Steps to Reproduce

Try to define an aspect for @GrpcExceptionHandler annotated methods. The aspect will not be applied to target.

The application's environment

Which versions do you use?

  • Spring (boot): 2.3.5.RELEASE
  • grpc-java: 1.35.0
  • grpc-spring-boot-starter: 2.11.0.RELEASE
  • java: version + architecture (64bit?) java15
  • Other relevant libraries...

Additional context

  • Did it ever work before? - no
  • Do you have a demo? - no
@ST-DDT
Copy link
Collaborator

ST-DDT commented Mar 23, 2021

Should be fixed in https://github.com/yidongnan/grpc-spring-boot-starter/pull/515

Thanks for bringing this to our attention.

@ST-DDT ST-DDT self-assigned this Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants