NEWRELIC-6338 NullPointerException thrown when calling addCustomAttributes #1141
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.
[Before contributing, please read our contributing guidelines and code of conduct.](https://issues.newrelic.com/browse/NEWRELIC-6338)
Overview
null guards shouldAddAttribute
Related Github Issue
Include a link to the related GitHub issue, if applicable
[NOTE]: # In a least one use case, a NullPointerExeception is thrown when calling any of the addCustomAttribute or addCustomAttributes method on TracedMethod. The exception is being thrown in the shouldAddAttribute() of AbstractTracer.
Description
If the following is true then a NullPointerExeception is thrown by the Agent, The async token is created but no transaction is started (No-op token created). If a method is called with the @trace attribute async set to true and the token is linked then if you try to add an attribute to TracedMethod it results in a NullPointerExeception. This seems to happen because when the resulting TransactionActivity is created its Transaction object is set to null.
In some cases it results in the application not working properly.
Testing
Testing against provided repro app
Checks
[ ] Are your contributions backwards compatible with relevant frameworks and APIs?
[ ] Does your code contain any breaking changes? Please describe.
[ ] Does your code introduce any new dependencies? Please describe.