night-config
night-config copied to clipboard
De serializing a Map results in a Null pointer ex
class A {
@Path("a")
Map<String, String> map;
}
a: {
"b": "C"
}
throws
java.lang.NullPointerException
at com.electronwill.nightconfig.core.conversion.ObjectConverter.convertToObject(ObjectConverter.java:202)
at com.electronwill.nightconfig.core.conversion.ObjectConverter.convertToObject(ObjectConverter.java:239)
at com.electronwill.nightconfig.core.conversion.ObjectConverter.toObject(ObjectConverter.java:101)
at com.electronwill.nightconfig.core.conversion.ObjectConverter.toObject(ObjectConverter.java:114)
while (clazz != Object.class) {
.....
clazz = clazz.getSuperclass();
}
all java interfaces return null here, but i assume that the bug lies elsewhere, as the library is able to deserialize field with types such as List and Set
Collections benefit from a custom logic, Maps aren't handled by ObjectConverter.toObject
for now.
I'll fix it for the next release. Thanks for reporting!
Meanwhile, you can replace the map by a Config
and use its valueMap()
.