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

Fix method reflection bug #5030

Merged

Conversation

BlackBear2003
Copy link
Member

@BlackBear2003 BlackBear2003 commented Dec 3, 2023

What's the purpose of this PR

Fix bug when aop finding method with same name by reflect.

Which issue(s) this PR fixes:

Fixes #5029

Brief changelog

enhance ApolloAuditSpanAspect::findMethod and its unit test method.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Update the CHANGES log.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 3, 2023
Copy link

codecov bot commented Dec 3, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (bc55ba6) 49.27% compared to head (7df860f) 49.62%.
Report is 2 commits behind head on master.

Files Patch % Lines
...mework/apollo/audit/aop/ApolloAuditSpanAspect.java 90.47% 2 Missing and 2 partials ⚠️
...ollo/audit/component/ApolloAuditLogApiJpaImpl.java 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5030      +/-   ##
============================================
+ Coverage     49.27%   49.62%   +0.35%     
- Complexity     1889     1904      +15     
============================================
  Files           372      372              
  Lines         11538    11559      +21     
  Branches       1123     1127       +4     
============================================
+ Hits           5685     5736      +51     
+ Misses         5513     5483      -30     
  Partials        340      340              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Method method = ReflectUtils.findDeclaredMethod(clazz, methodName, parameterTypes);
return method;
} catch (NoSuchMethodException e) {
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary for the caller to implement handling mechanisms for null value scenarios?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my late response, this method is trying to get the method which cause this method called.

So, when this method returns null, that would be a very strange situation.

Maybe just add a patch to end the audit logic rapidly when method returns null.

Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 4, 2023
@nobodyiam nobodyiam merged commit b67db2b into apolloconfig:master Dec 4, 2023
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2023
@nobodyiam nobodyiam added this to the 2.2.0 milestone Dec 4, 2023
@BlackBear2003 BlackBear2003 deleted the fix-method-reflection-bug branch December 4, 2023 07:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error occurred when creating namespace
2 participants