Skip to content

PropertyDescriptorUtils does not reliably resolve overloaded write methods #36113

@sbrannen

Description

@sbrannen

Overview

After fixing the bugs related to #36019, I noticed that PropertyDescriptorUtils still does not reliably resolve the correct write method if an overloaded candidate write method has a parameter type that is a subtype of another candidate write method whose parameter is an exact match for the resolved read method's return type. Whereas, we should always select an exact match for the write method whenever possible.

Although we consider this a bug, we currently only plan to fix this in 7.0.x, thereby foregoing a backport to 6.2.x that could result in regressions in the 6.2.x line which we would like to avoid.

Example

@Test
void resolvePropertiesWithUnresolvedGenericsInSubclassWithOverloadedSetter() {
var pdMap = resolver.resolve(PersonWithOverloadedSetter.class);
Class<?> writeType = Number.class;
if (resolver instanceof BasicPropertiesResolver) {
// TODO: PropertyDescriptorUtils currently incorrectly resolves setId(Integer)
// as the write method instead of setId(Number) (where Number is the
// unresolved generic for Long).
writeType = Integer.class;
}
assertReadAndWriteMethodsForClassAndId(pdMap, Number.class, writeType);
}

Related Issues

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions