-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unclear integration of Multi-Release Jar of jackson in cucumber-core #2786
Comments
Your impression is correct. As a test framework, Cucumber shouldn't interfere with the system under test. So Jackson is shaded in to avoid just that. Unfortunately Jackson is a moving target, and rather quick at that. We've had comparable problems in the past e.g. #2620. I would welcome a PR that resolves this. Unfortunately I can't currently investigate the issue in more detail. The correct solution however would ensure that the shaded Jackson works for Cucumber -- which uses a rather limited feature set -- so excluding It would also be nice if we could configure something to check this doesn't happen in the future. |
I'm getting issues with Jackson v2.15.2 on another project, but v2.15.1 works fine. |
Cucumber-JVM uses Jackson Databind to write json. Because Jackson is a very common dependency, to ensure we do not interfere with the system under test, we shade it. Unfortunately the Shade plugin occasionally gets updates and now includes multi-releases. These were not included in the relocation pattern and result in duplicate classes when Cucumber itself is shaded. As `cucumber-core` is not a multi-release jar, we can exclude the multi- release files altogether. Fixes: #2786
Cucumber-JVM uses Jackson Databind to write json. Because Jackson is a very common dependency, to ensure we do not interfere with the system under test, we shade it. Unfortunately the Shade plugin occasionally gets updates and now includes multi-releases. These were not included in the relocation pattern and result in duplicate classes when Cucumber itself is shaded. As `cucumber-core` is not a multi-release jar, we can exclude the multi- release files altogether. Fixes: #2786
🤔 What's the problem you've observed?
I think that the Multi Release jar related jackson classes are not included correctly in the cucumber-core module. As far as I can see, is the maven-shade plugin used by cucumber-core to include the jackson classes into the own jar under a different package. But jackson-core is a Multi Release jar and the corresponding classes reside in the META-INF/versions directory inside the jar. These classes are also "shaded" into the cucumber-core jar. Decompiling the classes shows that the package declarion has changed to the new subpackage. But inside the jar they still reside in the old directory/package "com.faster.xml.jackson.core.io.doubleparser". Also the "Multi-Release: true" property inside the MANIFEST.MF file is missing so that even if they classes would exist in the correct directory the "MultiRelease" features would now work as expected.
Why is this a problem / How did we notice it?
I am sure jackson has its reason for supporting MRJAR which is effectively negated by the way it is integrated into cucumber. We only noticed this because we have the enforcer plugin checking for duplicate classes in a projects that has a dependency on cucumber (7.13.0) and jackson (2.15.2).
Executing
mvn clean verify
a project with the following simplified example pom shows that the maven enforcer plugin does detect duplicate classes, which should, if I understand it correctly not be duplicated.We could configure the enforcer to exclude the related classes but that does not change our impression that something is not quite right.
✨ Do you have a proposal for making it better?
If the shading of jackson is a requirement I think there are two options.
I am unsure if this is really a problem of cucumber or the shade plugin or jackson or a combination of all but maybe you can say something about this. That is the reason why I created a "Developer experience" issues instead of a bug.
📚 Any additional context?
This text was originally generated from a template, then edited by hand. You can modify the template here.
The text was updated successfully, but these errors were encountered: