Home > database >  Trying to figure out differences between `mongodb-driver-sync v 4.6.0` and `mongo-java-driver v 3.12
Trying to figure out differences between `mongodb-driver-sync v 4.6.0` and `mongo-java-driver v 3.12

Time:06-02

We're using CongoMongo toolkit in our Clojure project:

https://github.com/congomongo/congomongo

It depends on a legacy Java driver (in project.clj):

[org.mongodb/mongo-java-driver "3.12.10"]

I'm now trying to roll my own Clojure wrapper because we need to upgrade to the modern API. It references :

[org.mongodb/mongodb-driver-sync "4.6.0"]

Including both in our project caused a conflict:

Syntax error (IllegalAccessError) compiling at (/tmp/form-init13152456523068551352.clj:1:74).
failed to access class com.mongodb.client.internal.MongoClientDelegate from class com.mongodb.Mongo (com.mongodb.client.internal.MongoClientDelegate and com.mongodb.Mongo are in unnamed module of loader 'app')

I then changed my wrapper to use the same 3.12.10 driver. Now everything works fine. CongoMongo is using the legacy driver, my wrapper is using the modern driver, and there's no conflict.

Is this expected behaviour? Does mongo-java-driver include both the legacy driver and the modern driver? Or is there a difference I should be aware about?

CodePudding user response:

Yes, the 3.x series of drivers contains both the legacy API and the modern API but the 3.x series only contains the modern API.

You can see this by looking in the JAR files:

(! 802)-> jar tvf ~/.m2/repository/org/mongodb/mongodb-driver-sync/4.6.0/mongodb-driver-sync-4.6.0.jar|fgrep ClientOptions

(! 803)-> jar tvf ~/.m2/repository/org/mongodb/mongodb-driver-core/4.6.0/mongodb-driver-core-4.6.0.jar|fgrep ClientOptions

(! 804)-> jar tvf ~/.m2/repository/org/mongodb/mongo-java-driver/3.12.0/mongo-java-driver-3.12.0.jar|fgrep ClientOptions
 20111 Tue Dec 10 09:49:24 PST 2019 com/mongodb/MongoClientOptions.class
   226 Tue Dec 10 09:49:24 PST 2019 com/mongodb/MongoClientOptions$1.class
 18642 Tue Dec 10 09:49:24 PST 2019 com/mongodb/MongoClientOptions$Builder.class

(! 805)-> jar tvf ~/.m2/repository/org/mongodb/mongodb-driver-sync/4.6.0/mongodb-driver-sync-4.6.0.jar|fgrep ClientSetting

(! 806)-> jar tvf ~/.m2/repository/org/mongodb/mongodb-driver-core/4.6.0/mongodb-driver-core-4.6.0.jar|fgrep ClientSetting
   229 Mon Apr 18 23:54:24 PDT 2022 com/mongodb/MongoClientSettings$1.class
 16809 Mon Apr 18 23:54:24 PDT 2022 com/mongodb/MongoClientSettings$Builder.class
 12947 Mon Apr 18 23:54:24 PDT 2022 com/mongodb/MongoClientSettings.class

(! 807)-> jar tvf ~/.m2/repository/org/mongodb/mongo-java-driver/3.12.0/mongo-java-driver-3.12.0.jar|fgrep ClientSetting
   229 Tue Dec 10 09:49:24 PST 2019 com/mongodb/MongoClientSettings$1.class
  9292 Tue Dec 10 09:49:24 PST 2019 com/mongodb/MongoClientSettings.class
 14842 Tue Dec 10 09:49:24 PST 2019 com/mongodb/MongoClientSettings$Builder.class

MongoClientOptions is part of the legacy API, MongoClientSettings is part of the modern API.

  • Related