-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.12.0
-
Component/s: POJO
-
None
-
Environment:java 8, documentdb(aws)
I am getting NPE at DecoderContext. The issue presents rarely, about 5% of the time, but when it does is at server start. Once it happens, all other calls to the same find method decoder fail with the same error.
There are other tickets JAVA-3376 and that describe the same problem but has not been addressed, and the tickets are now closed.JAVA-3456
If possible, please provide an intermediate improvement to improve the error response (NPE does not include any context information). Maybe providing the context of the call in the exception would help to find the issue:
PojoCodecImpl#decodePropertyModel(){ ... if (propertyModel.getCachedCodec()==null) throw new CodecConfigurationException("no cached codec reading x in codec y")
Notes
- codecs are loaded using the default automatic codec builder on the main registry: PojoCodecProvider.builder().automatic(true).build();
- The POJO structure is relatively large (9 classes) but does not have cycles.
- The system runs many parallel threads, the main codec registry seems to create multiple (equivalent?) codec instances when first invoked, but the last codec built seems to be cached and returned afterwards.
java.lang.NullPointerException at org.bson.codecs.DecoderContext.decodeWithChildContext(DecoderContext.java:93) at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:213) at org.bson.codecs.pojo.PojoCodecImpl.decodeProperties(PojoCodecImpl.java:197) at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:121) at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:125) at org.bson.codecs.pojo.LazyPojoCodec.decode(LazyPojoCodec.java:57) at org.bson.codecs.DecoderContext.decodeWithChildContext(DecoderContext.java:93) at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:213) at org.bson.codecs.pojo.PojoCodecImpl.decodeProperties(PojoCodecImpl.java:197) at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:121) at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:125) at org.bson.codecs.pojo.AutomaticPojoCodec.decode(AutomaticPojoCodec.java:37) at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52) at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:60) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41) at org.bson.internal.LazyCodec.decode(LazyCodec.java:48) at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101) at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:63) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41) at com.mongodb.internal.connection.ReplyMessage.<init>(ReplyMessage.java:51) at com.mongodb.internal.connection.InternalStreamConnection.getCommandResult(InternalStreamConnection.java:413) at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:309) at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:259) at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99) at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:450) at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72) at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:226) at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269) at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131) at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:123) at com.mongodb.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:343) at com.mongodb.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:334) at com.mongodb.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:220) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:731) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:725) at com.mongodb.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:463) at com.mongodb.operation.FindOperation.execute(FindOperation.java:725) at com.mongodb.operation.FindOperation.execute(FindOperation.java:89) at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:196) at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:143) at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92) at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:39) at java.lang.Iterable.spliterator(Iterable.java:101) at Dao.findAll(Dao.java:123) ...