Copilot commented on code in PR #7867:
URL: https://github.com/apache/incubator-seata/pull/7867#discussion_r2625779170
##########
integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/interceptor/parser/GlobalTransactionalInterceptorParser.java:
##########
@@ -88,8 +89,13 @@ protected boolean existsAnnotation(Class<?>... classes) {
if (trxAnno != null) {
return true;
}
- Method[] methods = clazz.getMethods();
+ Method[] methods = clazz.getDeclaredMethods();
Review Comment:
Changing from `getMethods()` to `getDeclaredMethods()` may miss annotations
on inherited methods from parent classes. The `getMethods()` method returns all
public methods including those inherited from superclasses, while
`getDeclaredMethods()` only returns methods declared directly in this class. If
a parent class has a method annotated with `@GlobalTransactional` or
`@GlobalLock`, it will not be detected when scanning the child class. Consider
iterating through the class hierarchy or keeping `getMethods()` while adding
the private method filter.
##########
integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/interceptor/parser/GlobalTransactionalInterceptorParser.java:
##########
@@ -88,8 +89,13 @@ protected boolean existsAnnotation(Class<?>... classes) {
if (trxAnno != null) {
return true;
}
- Method[] methods = clazz.getMethods();
+ Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
+ // exclude private modifier methods
+ if (Modifier.isPrivate(method.getModifiers())) {
+ continue;
+ }
Review Comment:
The new behavior of excluding private methods and including non-private
methods (protected and package-private) lacks test coverage. Consider adding
test cases with method-level `@GlobalTransactional` or `@GlobalLock`
annotations on protected, package-private, and private methods to verify that:
1) private methods are correctly excluded, 2) protected and package-private
methods are correctly included. Currently all tests only use class-level
annotations.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]