Using Enums with the PojoCodecProvider.Builder.automatic(true) causes a NPE.
Was
======
Hi again,
I'm trying to use java mongo drive 3.6 to save pojo's in db.
However, if my pojo contains method:
@BsonIgnore public MyEnum getSomeValue() { ... compute and return value... }
I get NullPointerException in PojoCodecImpl:shouldSpecialize (:332)
In typeParameterMap there is: "cachedConstructor" : "0=0"
but when the code looks for the "cachedConstructor" in classModel.getPropertyModel ,it finds nothing. So classModel.getPropertyModel((String)entry.getKey()).getCodec() ends in NPE.
If I change the name of the metod (so that it is not mistaken with a getter):
@BsonIgnore public MyEnum someValue() { ... compute and return value... }
I get a
Error: org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class
If I remove this method from my pojo, everything works fine.
In general I assume I can have multiple methods that are not getters and setters - and that they will not interfere with saving the pojo. I have added @BsonIgnore to be sure - but it seems that this method is not ignored.
- is duplicated by
-
JAVA-2714 EnumCodec stop to work
- Closed