Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-4698

MetricsManagers' remove method may cause a NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.27.0, 2.27.1, 2.28.0, 2.29.0, 2.30.0, 2.31.0, 2.31.1, 2.31.2, 2.32.0, 2.33.0
    • 2.34.0
    • None
    • None

    Description

      I recently switched from Artemis-server 2.19.1 to 2.31.1. From this point, I have been experiencing a lot the following errors: 

      AMQ224065: Failed to remove auto-created queue xyz

      The stack trace shows that this consistenly happens in the remove call of the MetricsManager. More specifically, the logger.debug statement which uses the removed variable:

      java.lang.NullPointerException: Cannot invoke "io.micrometer.core.instrument.Meter.getId()" because "removed" is null
        at org.apache.activemq.artemis.core.server.metrics.MetricsManager.remove(MetricsManager.java:167)

      This did not happen in the previous version, as prior to ARTEMIS-4020 the log statement was conditional based on whether debug logging was enabled. 

      While the issue at hand may be caused by my application (un)registering additional metrics on some queues, I feel the MeterRegistry should include a null-check for the value of removed, as by the JavaDoc of Micrometers' MeterRegistry, the meterRegistry.remove will return:

      The removed meter, or null if the provided meter is not currently registered.

      Also, as a null from the MeterRegistry means that the metric no longer exists, as this is a remove call that should not be a blocking issue. 

      I currently work around the issue using a class overload with an inline null check:

      logger.debug("Unregistered meter: {}", removed != null ? removed.getId() : "null");

      Attachments

        Issue Links

          Activity

            People

              jbertram Justin Bertram
              jellesmits Jelle Smits
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m