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

$set fails when setting sub-document as a Map

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: 3.1.0
    • Component/s: Codecs
    • Labels:
      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@mongodb.com Ross Lawley
            Reporter:
            bhunt@nvidia.com Bryan Hunt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: