Skip to content
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

Don't throw if no RPMServiceManager #1604

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Don't throw if no RPMServiceManager #1604

merged 1 commit into from
Nov 27, 2023

Conversation

jeffalder
Copy link
Contributor

Overview

We occasionally get an NPE in our logs

java.lang.NullPointerException: Cannot invoke "com.newrelic.agent.RPMServiceManager.getRPMService()" because the return value of "com.newrelic.agent.service.ServiceManager.getRPMServiceManager()" is null
	at com.newrelic.agent.service.ServiceFactory.getRPMService(ServiceFactory.java:103)
	at com.newrelic.agent.AgentImpl.getLinkingMetadata(AgentImpl.java:154)
	at com.newrelic.agent.bridge.logging.AppLoggingUtils.getLinkingMetadataBlob(AppLoggingUtils.java:57)

It looks like it comes from here, so I added a guard. AgentLinkingMetadata.getLinkingMetadata already handles the case if IRPMService is null, but I figured some linking metadata was better than none.

An alternative implementation would simply bypass this entirely if there was no entity guid yet. I'm not sure which way we want to go, but not getting an NPE seems preferable.

Related Github Issue

Fixes #1553

Testing

The agent includes a suite of tests which should be used to
verify your changes don't break existing functionality. These tests will run with
Github Actions when a pull request is made. More details on running the tests locally can be found
here,

Checks

  • Your contributions are backwards compatible with relevant frameworks and APIs.
  • Your code does not contain any breaking changes. Otherwise please describe.
  • Your code does not introduce any new dependencies. Otherwise please describe.

@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (68f1efb) 70.64% compared to head (0fbaa92) 70.64%.

Files Patch % Lines
...nt/src/main/java/com/newrelic/agent/AgentImpl.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1604   +/-   ##
=========================================
  Coverage     70.64%   70.64%           
  Complexity     9912     9912           
=========================================
  Files           826      826           
  Lines         39799    39802    +3     
  Branches       6009     6010    +1     
=========================================
+ Hits          28117    28120    +3     
+ Misses         8970     8969    -1     
- Partials       2712     2713    +1     

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

@jasonjkeller
Copy link
Contributor

@jeffalder Thanks for the fix. This looks good to me. We'll get it into the next agent release.

@jasonjkeller jasonjkeller merged commit 7f02208 into newrelic:main Nov 27, 2023
@jeffalder jeffalder deleted the npe-rpm-service branch November 28, 2023 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

NullPointerException caused by call to getLinkingMetadata before RPMService was initialized
3 participants