MethodProperty only checks for generic type in getters, not setters
public MethodProperty(PropertyDescriptor property) {
super(property.getName(), property.getPropertyType(),
property.getReadMethod() == null ? null : property.getReadMethod()
.getGenericReturnType());
this.property = property;
this.readable = property.getReadMethod() != null;
this.writable = property.getWriteMethod() != null;
}
The problem occurs in line 39:
property.getReadMethod() == null ? null : property.getReadMethod()
.getGenericReturnType()
The call to getGenericReturnType()
is used if there's a read method. But if there's no read method, only a write method, we use the value null
here, and lose the generic type information and incorrectly construct a List<>
(maybe a Map<>
, not sure; this happened to me) with the wrong type and not decode regular YAML mappingnodes as custom objects during YAML construction from a file.
It should be something like (not 100% sure of this)
property.getReadMethod() == null
? getWriteMethodGenericType(property)
: property.getReadMethod().getGenericReturnType()
with
Type getWriteMethodGenericType(PropertyDescriptor)
{
return property.getWriteMethod().getGenericParameterTypes().get(0); // ?? not sure
}
Comments (6)
-
-
reporter sorry, no time whatsoever (even to try something out) in the next few months
-
- changed status to on hold
To be reminded for the next release in August 2016
-
Issue
#382was marked as a duplicate of this issue. -
- changed status to resolved
fixes
#322and#382Now in case of missing readMethod we are trying to "guess" MethodProperty type from writeMethod's first (should be the only) parameter.→ <<cset 55b33e57b1ab>>
-
It will be delivered in version 1.19
- Log in to comment
Jason, do you wish to contribute code for this issue ?