Skip to content

TomcatMetricsBinder may log a warning for an NPE if the context is closed before the ApplicationStartedEvent is published #22141

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

Closed
wants to merge 1 commit into from

Conversation

im47cn
Copy link
Contributor

@im47cn im47cn commented Jun 28, 2020

fix for NPE in my unit test.

2020-06-28 10:40:25.832 - org.springframework.beans.factory.support.DisposableBeanAdapter -467378 [SpringContextShutdownHook] WARN  [] - Invocation of destroy method failed on bean with name 'tomcatMetricsBinder': java.lang.NullPointerException

fix for NPE in my unit test.

````
2020-06-28 10:40:25.832 - org.springframework.beans.factory.support.DisposableBeanAdapter -467378 [SpringContextShutdownHook] WARN  [] - Invocation of destroy method failed on bean with name 'tomcatMetricsBinder': java.lang.NullPointerException
````
@pivotal-issuemaster
Copy link

@im47cn Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@im47cn Thank you for signing the Contributor License Agreement!

@im47cn im47cn changed the title Update TomcatMetricsBinder.java Update TomcatMetricsBinder.java for NPE in unit test Jun 28, 2020
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 28, 2020
@wilkinsona wilkinsona changed the title Update TomcatMetricsBinder.java for NPE in unit test TomcatMetricsBinder may NPE if the context is closed before the ApplicationStartedEvent is published Jun 28, 2020
@wilkinsona wilkinsona added this to the 2.2.x milestone Jun 28, 2020
@wilkinsona wilkinsona added type: bug A general bug for: merge-with-amendments Needs some changes when we merge and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 28, 2020
@wilkinsona wilkinsona changed the title TomcatMetricsBinder may NPE if the context is closed before the ApplicationStartedEvent is published TomcatMetricsBinder may log a warning for an NPE if the context is closed before the ApplicationStartedEvent is published Jun 30, 2020
wilkinsona pushed a commit that referenced this pull request Jun 30, 2020
Previously, if TomcatMetricsBinder destroy() was called before it had
received an ApplicationStartedEvent an NPE would be thrown due to
TomcatMetrics being null. This NPE was then caught and logged at
warning level by the disposable bean adapter.

This prevents the NPE by checking that the TomcatMetrics instance is
null before calling close() on it.

See gh-22141
@wilkinsona wilkinsona modified the milestones: 2.2.x, 2.2.9 Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: merge-with-amendments Needs some changes when we merge type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants