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

Instantiating Cache in a custom system class loader leads to a recursive invocation exception #6565

Closed
01es opened this issue Jun 20, 2023 · 4 comments
Assignees
Labels
P2 package=cache type=defect Bug, not working as expected

Comments

@01es
Copy link

01es commented Jun 20, 2023

Having a custom system class loader, which instantiates com.google.common.cache.Cache as part of its construction results in recursive invocation exception.

The error occurs in line 240 of com.google.common.cache.CacheBuilder. The code comment suggests that this situation was envisaged. This was working correctly in version 31.1-jre and the error started to manifest in version 32.0.0-jre.

image
@cpovirk
Copy link
Member

cpovirk commented Jun 20, 2023

Thanks.

I can back out that change. In the abstract, I would say that "using Guava from a system class loader" is a use case that we wouldn't necessarily go to much effort to support, so no guarantees on future support for this in general. But please do let us know of other such problems, and if they're as easy to fix as this one, we can probably take care of them, too. (As you saw, we have at least one such class loader internally, so that code might continue to catch some problems that might otherwise affect you.)

@cpovirk
Copy link
Member

cpovirk commented Jun 20, 2023

If you're in a position to build your own copy of Guava with the fix and verify that this is the only problem lambda, that could help: The Guava release that fixes this will be the third release in about a month, so I'd love if we could avoid having to release a fourth with an additional fix :)

@01es
Copy link
Author

01es commented Jun 21, 2023

@cpovirk, thank you for your comment re "using Guava from a system class loader" – something to keep in mind moving forward.

I have checkout the source under tag v32.0.1, made the change (patch) as depicted below, and voila – everything works at our end. Thank you.
image

copybara-service bot pushed a commit that referenced this issue Jun 21, 2023
Fixes #6565

RELNOTES=`cache`: Fixed `BootstrapMethodError` when [using `CacheBuilder` from a custom system class loader](#6565).
PiperOrigin-RevId: 541928922
copybara-service bot pushed a commit that referenced this issue Jun 23, 2023
This is progress toward addressing the Java agent / `premain` problem discussed in #6566.

(And we're careful to avoid lambdas and method references so as to avoid #6565.)

RELNOTES=Fixed some problems with [using Guava from a Java Agent](#6566). (But we don't test that configuration, and we don't know how well we'll be able to keep it working.)
PiperOrigin-RevId: 542247494
copybara-service bot pushed a commit that referenced this issue Jun 23, 2023
This is progress toward addressing the Java agent / `premain` problem discussed in #6566.

(And we're careful to avoid lambdas and method references so as to avoid #6565.)

RELNOTES=Fixed some problems with [using Guava from a Java Agent](#6566). (But we don't test that configuration, and we don't know how well we'll be able to keep it working.)
PiperOrigin-RevId: 542887194
@cpovirk
Copy link
Member

cpovirk commented Jun 30, 2023

The fix landed in 32.1.0, but because we got the Gradle metadata wrong in that release, I suggest going straight to 32.1.1, which also contains the fix for that problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 package=cache type=defect Bug, not working as expected
Projects
None yet
2 participants