Open felipebernardes opened 7 years ago
I'm having a similar issue, when I tried to provide a null string to the fixture, it gives me an empty string.
After debugging this morning seems like a bug in the reflection logic around here
.
for (String parameterName : parameterNames) {
Class<?> fieldType = ReflectionUtils.invokeRecursiveType(templateHolder.getClazz(), parameterName);
Object result = processedArguments.get(parameterName); // [1]
if (result == null) { // nulls branch here
result = processChainedProperty(parameterName, fieldType, processedArguments);
}
values.add(transformerChain.transform(result, fieldType));
}
What's happening under the hood is that it considers that it doesn't find the parameter when it is but the value is actually null. Because of this it tries to instantiate the type using its default constructor:
Double
, there's no default constructor -> instantiation by reflection fails with the aforementioned errorString
, there is a default constructor that returns an empty string (what I'm seeing)A fix in the above snippet would be to handle when the key isn't present differently than when the value is null (see [1]
).
Hello folks,
Even so, I'm getting this error when trying to instantiate from a fixture with a null value in a Double field:
Could you please help me?
Thanks in advance && thanks for the great lib!