- Notifications
You must be signed in to change notification settings - Fork 327
null-safe weak set/map + detached thread local #1597
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
Conversation
Codecov Report
@@ Coverage Diff @@ ## master #1597 +/- ## ============================================ + Coverage 58.61% 58.69% +0.07% Complexity 92 92 ============================================ Files 396 399 +3 Lines 17805 17854 +49 Branches 2472 2474 +2 ============================================ + Hits 10437 10480 +43 + Misses 6653 6650 -3 - Partials 715 724 +9
Continue to review full report at Codecov.
|
eyalkoren left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two usages of WeakConcurrentMap that deliberately not use the factory (so they can use a dedicated cleaner thread) - let's replace those as well.
Also, worth looking into the already reported stack trace and see if we can find what's wrong:
2020-12-22 12:17:40,576 ERROR [stderr] (default task-1) java.lang.NullPointerException 2020-12-22 12:17:40,577 ERROR [stderr] (default task-1) at co.elastic.apm.agent.shaded.weaklockfree.WeakConcurrentMap.containsKey(WeakConcurrentMap.java:146) 2020-12-22 12:17:40,579 ERROR [stderr] (default task-1) at co.elastic.apm.agent.process.ProcessHelper.doStartProcess(ProcessHelper.java:66) 2020-12-22 12:17:40,580 ERROR [stderr] (default task-1) at co.elastic.apm.agent.process.ProcessHelper.startProcess(ProcessHelper.java:51) 2020-12-22 12:17:40,580 ERROR [stderr] (default task-1) at co.elastic.apm.agent.process.ProcessStartInstrumentation$ProcessBuilderStartAdvice.onExit(ProcessStartInstrumentation.java:77) 2020-12-22 12:17:40,581 ERROR [stderr] (default task-1) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071) 2020-12-22 12:17:40,581 ERROR [stderr] (default task-1) at java.base/java.lang.Runtime.exec(Runtime.java:591) 2020-12-22 12:17:40,582 ERROR [stderr] (default task-1) at java.base/java.lang.Runtime.exec(Runtime.java:450) ... ...ent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/weakmap/NullSafeWeakConcurrentMap.java Outdated Show resolved Hide resolved
apm-agent-plugin-sdk/src/main/java/co/elastic/apm/agent/sdk/weakmap/WeakMapSupplier.java Outdated Show resolved Hide resolved
| Let's also handle the NPEs coming from the |
| public static <T> boolean isNullKey(@Nullable T key){ | ||
| return true; | ||
| } | ||
| | ||
| public static <T> boolean isNullValue(@Nullable T value) { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, forgot to update those, it's not really surprising that test fails with that :-)
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
What does this PR do?
The
WeakConcurrentMapimplementation throwsNullPointerExceptionin the following cases:nullkey, or test ifnullkey entry existsnullvalueWhile trying to perform any of the above operations is a bug and should be avoided, we can't ensure that any instrumentation plugin will try to, causing errors and verbose log.
This PR provides a wrapper implementation for WeakConcurrentMap that will improve current implementation:
WARNlevelDEBUGlevel to allow easy identification of the root cause.Few caveats:
co.elastic.apm.agent.sdk.weakmap.WeakMapSupplier#createMapChecklist
log_level=debugwith packaged agentlog_level=warnwith packaged agent