ARTEMIS-4698 mitigate NPE when removing metrics

This commit is contained in:
Justin Bertram 2024-03-25 13:15:06 -05:00
parent 04f6424928
commit f36e944641
1 changed files with 5 additions and 1 deletions

View File

@ -168,7 +168,11 @@ public class MetricsManager {
logger.debug("Unregistering meters for {}", resource); logger.debug("Unregistering meters for {}", resource);
for (Meter meter : resourceMeters) { for (Meter meter : resourceMeters) {
Meter removed = meterRegistry.remove(meter); Meter removed = meterRegistry.remove(meter);
logger.debug("Unregistered meter: {}", removed.getId()); if (removed != null) {
logger.debug("Unregistered meter: {}", removed.getId());
} else {
logger.debug("Attempted to unregister meter {}, but it wasn't found in the registry", meter);
}
} }
} else { } else {
logger.debug("Attempted to unregister meters for {}, but none were found.", resource); logger.debug("Attempted to unregister meters for {}, but none were found.", resource);