[JAVA-3604] OSGi: Make mongodb-driver-sync dependency on mongodb-crypt optional Created: 24/Jan/20  Updated: 28/Oct/23  Resolved: 31/Jan/20

Status: Closed
Project: Java Driver
Component/s: Build, Client Side Encryption
Affects Version/s: 3.12.1
Fix Version/s: 3.12.2, 4.0.0

Type: Bug Priority: Minor - P4
Reporter: Josef Haertl Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Java with OSGi



 Description   

This seems quite similar and/or an follow-up to JAVA-3575 that still exists as of version 3.12.1.

The manifest.xml of mongodb-driver-sync declares a required import of

com.mongodb.crypt.capi;version="[1.0,2)" 

... which would be provided by mongodb-crypt

This is odd for multiple reasons

  1. Is mongodb-crypt required at all, even if not using any client side encryption?
    1. My unit-tests (not using osgi, so ignoring manifest.xml) seem to work without it and
    2. JAVA-3575 more or less hints that it should be optional.
  2. mongodb-driver-sync does not maven-depend on it (https://mvnrepository.com/artifact/org.mongodb/mongodb-driver-sync/3.12.1) at all.
    1. To some degree it was an optional dependency before JAVA-3575 via mongodb-driver-core.
    2. Currently there is no maven dependency at all. So, without manual addition, it won't run in osgi.

Probably 

com.mongodb.crypt.capi;version="[1.0,2)" 

should be declared optional?



 Comments   
Comment by Josef Haertl [ 31/Jan/20 ]

Great! Thanks for fixing this so quickly

Comment by Ross Lawley [ 31/Jan/20 ]

This will be released in 3.12.2

Comment by Githook User [ 30/Jan/20 ]

Author:

{'name': 'Ross Lawley', 'username': 'rozza', 'email': 'ross.lawley@gmail.com'}

Message: OSGI: Mark com.mongodb.crypt.capi as optional

Bnd needs some help marking optional dependency packages as optional.

JAVA-3604
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/cf098254162dd5ddccc19fa110c28238217f0173

Comment by Githook User [ 30/Jan/20 ]

Author:

{'name': 'Ross Lawley', 'username': 'rozza', 'email': 'ross.lawley@gmail.com'}

Message: OSGI: Mark com.mongodb.crypt.capi as optional

The OSGI plugin needs some help marking optional dependency packages as optional.

JAVA-3604
Branch: 3.12.x
https://github.com/mongodb/mongo-java-driver/commit/7b94afe67635b40d03886ca3156d6be36f5b64a1

Comment by Ross Lawley [ 30/Jan/20 ]

PR: https://github.com/rozza/mongo-java-driver/pull/361 (3.12.2)

Comment by Ross Lawley [ 30/Jan/20 ]

PR: https://github.com/rozza/mongo-java-driver/pull/360

Comment by Josef Haertl [ 27/Jan/20 ]

Hi Ross Lawley,

Yes, with "Currently there is no maven dependency at all" i meant that the (optional) dependency is not picked up while not beeing marked as optional. So, currently, one has to best guess that mongodb-crypt must be added in the maven build (as a workaround for now - on the long term, making it optional would be greatly prefereable)

Thanks for investigating

Josef Härtl

Comment by Ross Lawley [ 24/Jan/20 ]

Hi josef.haertl@ldbv.bayern.de,

Thanks for the ticket. Your correct the MongoCrypt dependency is an optional dependency of mongodb-driver-core and if the configuration uses encryption then it will be used by mongodb-driver-sync.

Unfortunately, JAVA-3575 seems to have fixed the driver-core MANIFEST but the bnd library didn't automatically mark the dependency as optional in sync / async.

2. Currently there is no maven dependency at all. So, without manual addition, it won't run in osgi.

Just to clarify; Is this because the optional dependency from driver-core won't be picked up by maven and in mongodb-driver-sync its not marked as optional?

Apologies for missing this in the higher level MANIFESTs.

Ross

Generated at Thu Feb 08 09:00:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.