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.