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

BlockingQueue and guard adding null #707

Merged
merged 4 commits into from
Mar 1, 2022
Merged

BlockingQueue and guard adding null #707

merged 4 commits into from
Mar 1, 2022

Conversation

tbradellis
Copy link
Contributor

@tbradellis tbradellis commented Feb 17, 2022

PR for:
#621

We intermittently see NPEs from:
at com.newrelic.agent.stats.StatsServiceImpl.doStatsWork(StatsServiceImpl.java:61) ~[newrelic.jar:7.4.2]
at com.newrelic.agent.service.ServiceManagerImpl.replayStartupStatsWork(ServiceManagerImpl.java:585)
Which is preventing application startup with the agent.
They get the following error in newrelic.log when that happens.

java.lang.NullPointerException: null
at com.newrelic.agent.stats.StatsServiceImpl.doStatsWork(StatsServiceImpl.java:61) ~[newrelic.jar:7.4.2]
at com.newrelic.agent.service.ServiceManagerImpl.replayStartupStatsWork(ServiceManagerImpl.java:585) ~[newrelic.jar:7.4.2]
at com.newrelic.agent.service.ServiceManagerImpl.doStart(ServiceManagerImpl.java:195) ~[newrelic.jar:7.4.2]
at com.newrelic.agent.service.AbstractService.start(AbstractService.java:63) ~[newrelic.jar:7.4.2]
at com.newrelic.agent.Agent.continuePremain(Agent.java:162) [newrelic.jar:7.4.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]

We have been unable to replicate the issue. However there is general agreement that we can and should just guard against the NPE in that spot. It's also possible that another thread causes an issue.

This PR changes the List holding StatsWork to a LinkedBlockingQueue and guards against attempting to add a null to the queue (which would throw an NPE for LBQ). Logs that this occurred.

Checks

@tbradellis tbradellis self-assigned this Feb 17, 2022
@tbradellis tbradellis added 7.6.0 GTSE There is an associated support escalation with this issue. labels Feb 17, 2022
ServiceFactory.getStatsService().doStatsWork(
StatsWorks.getRecordMetricWork(MessageFormat.format(MetricNames.SUPPORTABILITY_WEAVE_CLASS,
packageName, weaveResult.getClassName()), 1));
StatsWorks.getRecordMetricWork(weaveClassStat, 1), weaveClassStat);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change made the old code clearer.

@tbradellis tbradellis merged commit 533a5ce into main Mar 1, 2022
@tbradellis tbradellis deleted the statswork-npe branch March 1, 2022 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GTSE There is an associated support escalation with this issue.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Application unable to start intermittently after upgrading from 5.8.0 to 7.4.2
2 participants