Checklist
Description
Hello. We are trying to enable Jetty support for Virtual Threads and we hit an issue with GuavaCachedJwkProvider. It uses com.google.common.cache.LocalCache which is synchronized, causing thread pinning.
Reproduction
I found this by enabling this JVM option -Djdk.tracePinnedThreads=full, which produced the following stack trace (clamped to remove internal namespaces)
com.auth0.jwk.UrlJwkProvider.getJwks(UrlJwkProvider.java:136)
com.auth0.jwk.UrlJwkProvider.getAll(UrlJwkProvider.java:145)
com.auth0.jwk.UrlJwkProvider.get(UrlJwkProvider.java:163)
com.auth0.jwk.RateLimitedJwkProvider.get(RateLimitedJwkProvider.java:28)
com.auth0.jwk.GuavaCachedJwkProvider.lambda$get$0(GuavaCachedJwkProvider.java:62)
com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4860)
com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3551)
com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2302)
com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2177) <== monitors:1
com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2068)
com.google.common.cache.LocalCache.get(LocalCache.java:3986)
com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4855)
com.auth0.jwk.GuavaCachedJwkProvider.get(GuavaCachedJwkProvider.java:62)
Additional context
There is this issue in Guava repository, but it's closed as "won't fix" as they suggest using Caffeine for caching instead.
For reference, Spring has replaced Guava Caching with Caffeine: spring-projects/spring-framework#18370
jwks-rsa version
0.22.1
Java version
21
Checklist
Description
Hello. We are trying to enable Jetty support for Virtual Threads and we hit an issue with
GuavaCachedJwkProvider. It usescom.google.common.cache.LocalCachewhich issynchronized, causing thread pinning.Reproduction
I found this by enabling this JVM option
-Djdk.tracePinnedThreads=full, which produced the following stack trace (clamped to remove internal namespaces)Additional context
There is this issue in Guava repository, but it's closed as "won't fix" as they suggest using Caffeine for caching instead.
For reference, Spring has replaced Guava Caching with Caffeine: spring-projects/spring-framework#18370
jwks-rsa version
0.22.1
Java version
21