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

ConfigurationUtility.isMethodOverwrite inefficient reflection #1101

Open
wants to merge 1 commit into
base: releases/24.2
Choose a base branch
from

Conversation

paolobazzi
Copy link
Member

Add lazy initialized cache for declared methods for each queried class. Additionaly fetching all declared methods of a class avoids catching NoSuchMethodExceptions when trying to find a method.

359087

@paolobazzi paolobazzi self-assigned this Aug 13, 2024
@paolobazzi paolobazzi force-pushed the features/pbz/24.2/configutil-method-override branch 4 times, most recently from fffc854 to 79651b0 Compare August 14, 2024 16:05
Add lazy initialized cache for declared methods for each queried class.
Additionally fetching all declared methods of a class avoids
catching NoSuchMethodExceptions when trying to find a method.

359087
@paolobazzi paolobazzi force-pushed the features/pbz/24.2/configutil-method-override branch from 79651b0 to 85000fc Compare August 15, 2024 07:36
assertNotNull(methodName, "methodName must not be null");
Method declaredMethod = getDeclaredMethod(declaringType, methodName, parameterTypes);
if (declaredMethod == null) {
LOG.error("cannot find declared method {}.{}", declaringType.getName(), methodName);
Copy link
Member

Choose a reason for hiding this comment

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

Is log level error really correct? Maybe warn should be sufficient?

}
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.

We could also introduce a cache for the method signature (declaring class, name, param types). Then the search loop would no longer be necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants