Skip to content
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

JacocoCoverage_jarjar_deploy.jar's shading of Guava is incomplete, causing some user tests to fail with bazel coverage #15124

Closed
thirtyseven opened this issue Mar 25, 2022 · 1 comment
Assignees
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules

Comments

@thirtyseven
Copy link
Contributor

thirtyseven commented Mar 25, 2022

Description of the problem / feature request:

While upgrading our repo to Bazel 5.1 from 4.2.2, we found some Java tests that depend on Guava were now failing but only with bazel coverage, not with bazel test. Test failures gave this stacktrace:

java.lang.NoSuchFieldError: EXACT
	at com.google.common.net.InternetDomainName.findSuffixOfType(InternetDomainName.java:170)
	at com.google.common.net.InternetDomainName.<init>(InternetDomainName.java:151)
	at com.google.common.net.InternetDomainName.from(InternetDomainName.java:209)
        at <ourcode>

When stepping through in the debugger, I noticed that com.google.thirdparty.publicsuffix.PublicSuffixPatterns.EXACT was being loaded from JacocoCoverage_jarjar_deploy.jar, not the Guava jar being pulled in by the code under test. It seems JacocoCoverage has shaded com.google.common using JarJar, but not com.google.thirdparty, which is also part of Guava.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Run bazel coverage on a JUnit test that invokes com.google.common.net.InternetDomainName.from("example.com")

What operating system are you running Bazel on?

macOS 12.3

What's the output of bazel info release?

release 5.1.0

Any other information, logs, or outputs that you want to share?

This looks easy to fix, JacocoCoverage.jarjar just needs a rule to shade com.google.thirdparty.

@thirtyseven thirtyseven changed the title Classes in JacocoCoverage_jarjar_deploy.jar conflict with Guava causing user tests to fail only under bazel coverage JacocoCoverage_jarjar_deploy.jar's shading of Guava is incomplete, causing some user tests to fail with bazel coverage Mar 25, 2022
@thirtyseven
Copy link
Contributor Author

Created a minimal test case here: https://github.com/thirtyseven/bazel-coverage-bug-example

bazel test //java:Test passes, but bazel coverage //java:Test fails.

@ckolli5 ckolli5 added team-Rules-Java Issues for Java rules untriaged labels Mar 28, 2022
@comius comius added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Mar 29, 2022
@comius comius assigned c-mita and unassigned comius Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants