Skip to content

JAVA-4789: Make bson.record.codec module optional for OSGi #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2022

Conversation

Joscorbe
Copy link
Contributor

Currently the Java Driver can't be used in OSGi containers using a Java version lower than 17, which according to the compatibility matrix should not happen, as it should be compatible from Java 8+.

The problem is that there is a dependency of bson.codecs.record, which requires Java17+ according to its MANIFEST.MF:

Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))"

This change will make the Import-Package attribute for bson.codecs.record optional, meaning when trying to use it in a OSGi container it won't fail because the dependency can't be satisfied in lower versions than 17.

After building with this change applied, that line in the MANIFEST.MF file will look like this:

org.bson.codecs.record;resolution:=optional;version="[4.7,5)"

We can see above this line that the same approach is used for jdk.net.

This change will still require Java 17+ to build the driver, but allows its use in OSGi containers using lower versions.

JAVA-4789

@Joscorbe
Copy link
Contributor Author

Versions 4.6.x of the driver are also affected by this problem.

@jyemin jyemin self-requested a review October 25, 2022 13:01
@jyemin jyemin self-assigned this Oct 25, 2022
@jyemin jyemin merged commit f5a84d3 into mongodb:master Oct 25, 2022
@jyemin
Copy link
Collaborator

jyemin commented Oct 25, 2022

Backported to 4.7.x branch: 2f2e579.

@Joscorbe our policy is to backport fixes to the latest release branch, so this fix will be included in 4.7.3 (which will be released within a week) as well as the next minor release, 4.8.0.

@Joscorbe
Copy link
Contributor Author

Ok, that's fine. Thanks for checking it @jyemin!

jyemin added a commit that referenced this pull request Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants