Working on this ticket requires resolving JAVA-4745 / merging https://github.com/mongodb/mongo-java-driver/pull/1007 to avoid conflicts. The ticket is spawned as a result of this discussion.
Currently CodecCache.putIfMissing puts in a ConcurrentMap, but nevertheless is guarded with synchronized and does two put}}s for the same key. If we use {{ConcurrentMap.compute to reimplement the method, we can not only get rid of these oddities, but also improve its performance and, also importantly, readability.
Tangentially related to the above improvement, methods OverridableUuidRepresentationCodecRegistry.get, ProvidersCodecRegistry.get do two map lookups instead of one on the happy path, because they both use the anti-pattern "check if a binding is there and then find the binding again, this time return the value". This is also worth changing.