Fix NPE in JVMFlagAccess.setValue when getStringFlag returns null#11354
Open
matsumo-and wants to merge 1 commit into
Open
Fix NPE in JVMFlagAccess.setValue when getStringFlag returns null#11354matsumo-and wants to merge 1 commit into
matsumo-and wants to merge 1 commit into
Conversation
On some platforms (e.g. Apple Silicon / aarch64), getStringFlag returns null for flags like OnError and OnOutOfMemoryError because they are not accessible via the native JVM flag API. Calling .equals() on the null result causes a NullPointerException. Replace with Objects.equals to handle null safely. Signed-off-by: matsumo-and <yh134.toisanda@gmail.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Fixes a
NullPointerExceptioninJVMFlagAccess.setValueinside crash tracking initialization.setValuecallsgetStringFlagaftersetStringFlagto verify the write succeeded, butgetStringFlagcan returnnullon certain platforms where the JVM flag is not accessible viathe native ddprof API. The fix replaces
.equals()withObjects.equalsto handlenullsafely.Motivation
On Apple Silicon (aarch64) and potentially other platforms, JVM flags like
OnErrorandOnOutOfMemoryErrorare not readable viaJVMAccess.Flags.getStringFlag, which returnsnull.This caused a
NullPointerExceptionlogged as a WARN during crash tracking initialization onevery agent startup, polluting logs and causing noise in tests that assert no NPE appears.
Additional Notes
JVMFlagAccess(native path) is affected.JMXFlagAccessalways returnstrueand is unaffected.falsewhengetStringFlagreturnsnullis semantically correct: it signals thatthe flag could not be verified as set, which is the expected behavior when the native API does
not support the flag.
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issue