Skip to content

Why is DefaultDbRefResolver.LazyLoadingInterceptor avoiding ONLY the resolution process when method's declaring class is Object [DATAMONGO-1353] #2270

Open
@spring-projects-issues

Description

@spring-projects-issues

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)

Metadata

Metadata

Assignees

Labels

in: coreIssues in core supportin: mappingMapping and conversion infrastructuretype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions