Skip to content

Commit c4b40eb

Browse files
author
Miguel Gonzalez Sanchez
committed
cleanup code
1 parent 9d0ed77 commit c4b40eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

grpc-spring-boot-starter/src/main/java/org/lognet/springboot/grpc/autoconfigure/OnMissingErrorHandlerCondition.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
2828

2929
ReflectionUtils.MethodFilter f = method -> AnnotatedElementUtils.hasAnnotation(method, GRpcExceptionHandler.class);
3030
for (String adviceBeanName : context.getBeanFactory().getBeanNamesForAnnotation(GRpcServiceAdvice.class)) {
31-
final String beanClassName = getBeanClassName(context.getBeanFactory().getBeanDefinition(adviceBeanName));
31+
BeanDefinition beanDefinition = context.getBeanFactory().getBeanDefinition(adviceBeanName);
32+
String beanClassName = getBeanClassName(beanDefinition);
3233
try {
3334
for (Method method : MethodIntrospector.selectMethods(Class.forName(beanClassName), f)) {
3435
final Optional<Class<? extends Throwable>> handledException = HandlerMethod.getHandledException(method, false);
@@ -49,7 +50,7 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
4950
}
5051

5152
private String getBeanClassName(BeanDefinition beanDefinition) {
52-
if (beanDefinition instanceof AnnotatedBeanDefinition) { // definition with @Bean Annotation cause this issue
53+
if (beanDefinition instanceof AnnotatedBeanDefinition) {
5354
MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) beanDefinition).getFactoryMethodMetadata();
5455
return factoryMethodMetadata.getReturnTypeName();
5556
} else {

0 commit comments

Comments
 (0)