HY-love-sleep opened a new pull request, #7213:
URL: https://github.com/apache/shenyu/pull/7213

   ## What
   
   `TarsServiceBeanEventListener#getBeans` discovers servants with
   `context.getBeansWithAnnotation(ShenyuTarsService.class)` — Spring resolves 
that through interfaces
   and superclasses — but `buildMetaDataDTO` read the very same annotation with 
plain reflection:
   
   ```java
   String serviceName = 
clazz.getAnnotation(ShenyuTarsService.class).serviceName();
   ```
   
   `@ShenyuTarsService` is not `@Inherited` and `clazz` is the concrete servant
   (`AopUtils.getTargetClass(bean)`), so a servant that declares the annotation 
through its interface
   is discovered by the bean lookup and then crashes with an NPE while its 
metadata is built.
   
   The annotation is now resolved with 
`AnnotatedElementUtils.findMergedAnnotation` — the same lookup
   this class already uses for `@ShenyuTarsClient` a few lines above — plus a 
null guard.
   
   ## Why
   
   Closes #6790.
   
   ## Verified
   
   * 
`TarsServiceBeanPostProcessorTest#testPostProcessServantAnnotatedOnInterface` 
(new) registers a
     servant whose `@ShenyuTarsService` sits on the interface while 
`@ShenyuTarsClient` sits on the
     implementation, and drives the normal context-refresh path. Reverting the 
production change makes
     it fail with the reported `NullPointerException`; with the fix it passes.
   * `./mvnw -pl shenyu-client-tars -am test 
-Dtest='TarsServiceBeanPostProcessorTest,TarsRpcExtTest'`
     → **Tests run: 4, Failures: 0, Errors: 0**
   * checkstyle: 0 violations
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to