[JAVA-4381] mongodb-driver-legacy MANIFEST.MF should not include Automatic-Module-Name Created: 29/Oct/21 Updated: 28/Oct/23 Resolved: 02/Nov/21 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Packaging |
| Affects Version/s: | None |
| Fix Version/s: | 4.4.0 |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Jeffrey Yemin | Assignee: | Ross Lawley |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Case: | (copied to CRM) | ||||||||
| Description |
|
The mogodb-driver-legacy jar is not intended to include an Automatic-Module-Name in its MANIFEST.MF, but it does. The reason it should not is because it is not a valid Java module. One of the rules for modules is that the classes in any given package can not be split among multiple modules, and due to the way that packages were structured since the beginning of the driver, we had no choice but to split the "com.mongodb" package between mongodb-driver-core and mongodb-driver-legacy. That's because many of the classes that are used by the non-legacy API, e.g. com.mongodb.ReadPreference, are in the core mongodb-driver-core, while many of the legacy API classes, like com.mongodb.DBCollection are in the mongodb-driver-legacy jar. See section 2.3 of The State of the Module System for a more rigorous explanation of the restrictions on splitting packages across multiple modules:
That's why the build.gradle for driver-legacy doesn't specify an automatic module name. Compare that, for example to the build.gradle for driver-sync, which does. However, in publish.gradle we incorrectly specify a default Automatic-Module-Name for all jar files, and that's why mongdb-driver-legacy is ending up with one in its MANIFEST. And to add insult to injury, it's using the archiveBaseName as the name, and the archiveBaseName is not even a valid module name (since it contains dashes). We should remove this configuration from publish.gradle and rely on each jar to specify its own Automatic-Module-Name, and in the case of the legacy jar, not specify one at all. |
| Comments |
| Comment by Martin Prodanov [ 16/Feb/22 ] |
|
Hello, since the legacy driver is not a proper component how can it be used in an osgi environment? The current setup even with the fix does not seem to work as classes are spread around two modules.
Regards, Martin |
| Comment by Jeffrey Yemin [ 03/Nov/21 ] |
|
The 4.4.0-beta2 release is now available on Maven Central. Please give it a try. |
| Comment by Michael Pearson [ 02/Nov/21 ] |
|
Yeah we would like to move onto a stable version, but we also need to move fairly soon.
I think we could stomach moving onto a beta version, so if you'd be able to release another beta that'd be great.
|
| Comment by Jeffrey Yemin [ 02/Nov/21 ] |
|
Hi michael.pearson@canva.com, it's technically feasible, but given the diversity of tool chains out in the wild and our lack of testing with those tool chains, it feels risky to merge this in a patch release. I'm concerned that someone will try to upgrade to 4.3.4 and it will break their build. On the other hand, the Automatic-Module-Name is incorrect and that seems like a bug that should be fixed ASAP. Is the issue for you that you can't wait another week or two for 4.4.0 to come out, or that you are not in a position to upgrade to a new minor release even once it does come out. If it's the former, we could build another beta containing this fix and you could rely on that. In terms of quality, I would consider the beta production-ready. There are just a few more features we are trying to get in before GA. |
| Comment by Michael Pearson [ 02/Nov/21 ] |
|
Would it be possible to backport this to 4.3.x? https://github.com/mongodb/mongo-java-driver/pull/816 |
| Comment by Githook User [ 02/Nov/21 ] |
|
Author: {'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}Message: Fix mongodb-driver-legacy MANIFEST.MF (#815)
|