[JAVA-4789] Make bson.record.codec module optional for OSGi Created: 24/Oct/22  Updated: 28/Oct/23  Resolved: 27/Oct/22

Status: Closed
Project: Java Driver
Component/s: Build
Affects Version/s: None
Fix Version/s: 4.8.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
Backwards Compatibility: Minor Change
Documentation Changes: Needed

 Description   

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 the proposed change applied, that line in the MANIFEST.MF file will look like this:

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



 Comments   
Comment by Jeffrey Yemin [ 27/Oct/22 ]

Document in the release notes that for OSGi:

  • The bson.record.codec module is now optional
  • Any application that is relying on the driver to encode/decode Java records will need to add the dependency to bson.record.codec
Comment by Githook User [ 27/Oct/22 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Revert "Make bson.record.codec module optional for OSGi (#1024)"

This reverts commit 2f2e579e99a085d2e5a4f3812ab58fb303524406.

JAVA-4789
Branch: 4.7.x
https://github.com/mongodb/mongo-java-driver/commit/fd2f8cc988d4acdaaa1f65ae6def82ab9af2bfb0

Comment by Githook User [ 25/Oct/22 ]

Author:

{'name': 'José Andrés Cordero Benítez', 'email': 'Joscorbe@users.noreply.github.com', 'username': 'Joscorbe'}

Message: Make bson.record.codec module optional for OSGi (#1024)

JAVA-4789
Branch: 4.7.x
https://github.com/mongodb/mongo-java-driver/commit/2f2e579e99a085d2e5a4f3812ab58fb303524406

Comment by Githook User [ 25/Oct/22 ]

Author:

{'name': 'José Andrés Cordero Benítez', 'email': 'Joscorbe@users.noreply.github.com', 'username': 'Joscorbe'}

Message: Make bson.record.codec module optional for OSGi (#1024)

JAVA-4789
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/f5a84d3253f377e8e5fadaec01eee4c804c146e2

Comment by Cloud GitHub Webhooks [ 25/Oct/22 ]

jyemin merged a pull request (JAVA-4789 Make bson.record.codec module optional for OSGi) into the following branch:
master: f5a84d3253f377e8e5fadaec01eee4c804c146e2

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