Skip to content

Dual Caffeine support in the agent.#2807

Open
jtduffy wants to merge 27 commits intomainfrom
dual-caffeine-wildfly-fix
Open

Dual Caffeine support in the agent.#2807
jtduffy wants to merge 27 commits intomainfrom
dual-caffeine-wildfly-fix

Conversation

@jtduffy
Copy link
Contributor

@jtduffy jtduffy commented Mar 20, 2026

Overview

Resolves #2731

Implement support for Caffeine v2 and v3 in the agent. The version of Caffeine is selected based on the Java runtime version.

  • Caffeine 2.9.3 - For Java 8-10 (uses sun.misc.Unsafe)
  • Caffeine 3.2.3 - For Java 11+ (uses VarHandle)
Forcing Caffeine v2

A config exists, that if set to true, will force the use of Caffeine v2, even if the Java version is 11+:

  • System property: newrelic.config.collectionfactory.forcev2
  • Environment variable: NEW_RELIC_COLLECTIONFACTORY_FORCEV2

(Not available as a yaml config since the AgentCollectionFactory is loaded prior to any services being
spun up).

See the DualCaffeineReadme.md file for full details.

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 60.63830% with 148 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.33%. Comparing base (dad3cf9) to head (0df1cdc).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...ewrelic/agent/util/Caffeine2CollectionFactory.java 40.38% 61 Missing and 1 partial ⚠️
...ewrelic/agent/bridge/DefaultCollectionFactory.java 0.00% 26 Missing ⚠️
...om/newrelic/agent/util/AgentCollectionFactory.java 51.28% 14 Missing and 5 partials ⚠️
...a/com/newrelic/bootstrap/EmbeddedJarFilesImpl.java 42.10% 9 Missing and 2 partials ⚠️
...java/com/newrelic/weave/utils/WeakKeyLruCache.java 87.09% 5 Missing and 3 partials ⚠️
...om/newrelic/agent/bridge/CacheRemovalListener.java 0.00% 6 Missing ⚠️
...rc/main/java/com/newrelic/agent/TimedTokenSet.java 72.22% 3 Missing and 2 partials ⚠️
...n/weaver/extension/ExtensionHolderFactoryImpl.java 0.00% 3 Missing ⚠️
...gent/profile/v2/TransactionProfileSessionImpl.java 57.14% 3 Missing ⚠️
...va/com/newrelic/agent/config/JavaVersionUtils.java 50.00% 1 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2807      +/-   ##
============================================
- Coverage     70.38%   70.33%   -0.06%     
- Complexity    10386    10448      +62     
============================================
  Files           869      872       +3     
  Lines         42017    42250     +233     
  Branches       6386     6413      +27     
============================================
+ Hits          29575    29715     +140     
- Misses         9560     9638      +78     
- Partials       2882     2897      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spike] Java 26: Removal of sun.misc.Unsafe - Caffeine cache will cease to work

2 participants