Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3606

NullPointerException: DecoderContext.decodeWithChildContext

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 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 JAVA-3456 that describe the same problem but has not been addressed, and the tickets are now closed.

      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)
              ... 

       

        1. Reproducer.zip
          6 kB
        2. pojos.java
          2 kB
        3. 3.12.2-stack.txt
          5 kB

            Assignee:
            brian.deleonardis@mongodb.com Brian DeLeonardis (Inactive)
            Reporter:
            csamail@gmail.com Carlos S
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: