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

Avoid exceptions in ReflectionUtils.isObjectMethod(…) #22730

Closed
odrotbohm opened this issue Apr 3, 2019 · 1 comment
Closed

Avoid exceptions in ReflectionUtils.isObjectMethod(…) #22730

odrotbohm opened this issue Apr 3, 2019 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@odrotbohm
Copy link
Member

Currently, ReflectionUtils.isObjectMethod(…) calls Object.class.getDeclaredMethod(…), which, for every method that is not an object method, will cause an exception being thrown. I.e. if you call that method heavily with non-Object methods, you create a lot of exceptions.

I suggest to replace that method lookup by a Map lookup of all Object methods by name (with their parameter type arrays as value for subsequent comparison on a hit of the first lookup).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 3, 2019
@jhoeller jhoeller self-assigned this Apr 3, 2019
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 3, 2019
@jhoeller jhoeller added this to the 5.1.7 milestone Apr 3, 2019
@jhoeller
Copy link
Contributor

jhoeller commented Apr 3, 2019

Replaced with a direct check for Object as declaring class and delegation to the existing isEqualsMethod/isHashCodeMethod/isToStringMethod checks (which are the only overridable ones).

odrotbohm added a commit to spring-projects/spring-hateoas that referenced this issue Apr 3, 2019
Introduced more caches for reusable value objects: UriTemplate, MethodParameters. Cache UriTemplate.toString() to avoid re-computation. Avoid recomputing the affordances if possible in WebHandler. Removed cache in AnnotatedParametersParameterAccessor as that one now transitively benefits from the one introduced in MethodParameters.

Related ticket: spring-projects/spring-framework#22730.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants