spring-projects / spring-projects/spring-data-mongodb
Why is DefaultDbRefResolver.LazyLoadingInterceptor avoiding ONLY the resolution process when method's declaring class is Object [DATAMONGO-1353]
@odrotbohm is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Jordi Llach Fernandez opened DATAMONGO-1353 and commented
Code taken from the intercept method public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable of the above mentioned DefaultDbRefResolver.LazyLoadingInterceptor
...
if (isObjectMethod(method) && Object.class.equals(method.getDeclaringClass())) {
if (ReflectionUtils.isToStringMethod(method)) {
return proxyToString(proxy);
}
if (ReflectionUtils.isEqualsMethod(method)) {
return proxyEquals(proxy, args[0]);
}
if (ReflectionUtils.isHashCodeMethod(method)) {
return proxyHashCode(proxy);
}
// DATAMONGO-1076 - finalize methods should not trigger proxy initialization
if (FINALIZE_METHOD.equals(method)) {
return null;
}
...
}
I do not see any good reason for this check isObjectMethod(method) && Object.class.equals(method.getDeclaringClass(), and in fact proxyToString, proxyEquals and proxyHashCode implementations could always be used instead of the original ones, preventing the resolution process when for instance a proxy of this kind is stored in a map.
Maybe I am wrong
Affects: 1.7.2 (Fowler SR2)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.