$set fails when setting sub-document as a Map

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.5.0
    • Affects Version/s: 3.1.0
    • Component/s: Codecs
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If you try to use $set to update a sub-document as a Map, you get:

      Exception in thread "main" org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class java.util.HashMap.
      	at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
      	at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
      	at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
      	at com.mongodb.client.model.BuildersHelper.encodeValue(BuildersHelper.java:35)
      	at com.mongodb.client.model.Updates$SimpleUpdate.toBsonDocument(Updates.java:442)
      	at com.mongodb.MongoCollectionImpl.toBsonDocument(MongoCollectionImpl.java:599)
      	at com.mongodb.MongoCollectionImpl.update(MongoCollectionImpl.java:542)
      	at com.mongodb.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:381)
      	at com.mongodb.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:376)
      

      The attached project will reproduce the failure.

              Assignee:
              Ross Lawley
              Reporter:
              Bryan Hunt
              None
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: