Bug 1031200 - Error rendering metrics chart; Attempt to compare null values in queryResourceMetrics
Error rendering metrics chart; Attempt to compare null values in queryResourc...
Status: CLOSED CURRENTRELEASE
Product: RHQ Project
Classification: Other
Component: Core UI (Show other bugs)
4.9
Unspecified Unspecified
unspecified Severity unspecified (vote)
: GA
: RHQ 4.10
Assigned To: Lukas Krejci
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-15 16:23 EST by Elias Ross
Modified: 2014-04-23 08:31 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-04-23 08:31:07 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Elias Ross 2013-11-15 16:23:10 EST
Description of problem:

I've seen this problem, namely with the metrics pane:

http://...:7080/coregui/#Resource/253947/Monitoring/Metrics

Fri Nov 15 13:16:37 GMT-800 2013 
SEVERE: At [Fri Nov 15 13:16:37 GMT-800 2013] MessageCenter received: Globally uncaught exception BFEEEABEC1A9CFF9B91A5BEF7FF23A9C.cache.html:3460
Fri Nov 15 13:16:37 GMT-800 2013 
WARNING: Globally uncaught exception
com.google.gwt.core.client.JavaScriptException: (TypeError) 
 stack: TypeError: Cannot call method 'compareTo$' of null
    at Object.compare_0 [as compare] (<anonymous>:9013:40)
    at insertionSort (<anonymous>:8896:33)
    at mergeSort_0 (<anonymous>:8922:5)
    at mergeSort_0 (<anonymous>:8929:3)
    at mergeSort_0 (<anonymous>:8929:3)
    at mergeSort_0 (<anonymous>:8929:3)
    at mergeSort (<anonymous>:8915:3)
    at $queryResourceMetrics (<anonymous>:109611:3)
    at $onSuccess_434 (<anonymous>:109677:3)

I'm guessing that queryResourceMetrics is trying to sort something that's null:

    public void queryResourceMetrics(final Resource resource, Long startTime, Long endTime,
        final CountDownLatch countDownLatch) {
        Set<MeasurementDefinition> definitions = resource.getResourceType().getMetricDefinitions();

        //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
        final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
        for (MeasurementDefinition definition : definitions) {
            measurementDefMap.put(definition.getDisplayName(), definition);
        }
        //bundle definition ids for asynch call.
        definitionArrayIds = new int[definitions.size()];
        final String[] displayOrder = new String[definitions.size()];
        measurementDefMap.keySet().toArray(displayOrder);

So there are metric definitions that have a null display name?

This is with my own custom plugin.

Version-Release number of selected component (if applicable): 4.9


How reproducible: Always


Steps to Reproduce:
1. Create a metric definition with an empty display name (Oracle '' == null)
2. Display the metrics
3.

Actual results: Global Error


Expected results: Shows data.


Additional info:
Comment 1 Elias Ross 2013-11-15 18:02:32 EST
This is caused by a bad plugin:

How to reproduce:

1. Create two metrics with the same display name:

        <metric property="decr_misses" displayType="detail"
            displayName="Decr misses" description="Number of decr reqs against missing keys"
...
        <metric property="cas_misses" displayType="detail"
            displayName="Decr misses" description="Number of CAS reqs against missing keys"
            units="none" measurementType="trendsup"/>

The assumption in MetricsViewDataSource.java is that the number of definitions will match the number of unique display names.

        //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
        final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
        for (MeasurementDefinition definition : definitions) {
            measurementDefMap.put(definition.getDisplayName(), definition);
        }
        //bundle definition ids for asynch call.
        definitionArrayIds = new int[definitions.size()];

-> change to ->

        definitionArrayIds = new int[measurementDefMap.size()];
Comment 2 Lukas Krejci 2014-01-30 12:06:30 EST
Thanks for the BZ Elias.

commit 3cbe934a3b7f986ca816744bb2578bdfbad23e56
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Thu Jan 30 18:04:52 2014 +0100

    [BZ 1031200] - Don't assume unique display names of metrics
    While having unique names generally is true and even desirable, we were
    throwing NPE's in the UI due to that assumption.
    
    Now the UI will just correctly show 2 metrics with the same name which will
    hint the user correctly that there's something wrong with the plugin,
    not with RHQ itself.
Comment 3 Lukas Krejci 2014-01-30 12:08:29 EST
Note that the display name should never be empty. If it is not defined explicitly, it should be deduced from the name of the metric. The fix therefore doesn't account for null display names.
Comment 4 Heiko W. Rupp 2014-04-23 08:31:07 EDT
Bulk closing of 4.10 issues.

If an issue is not solved for you, please open a new BZ (or clone the existing one) with a version designator of 4.10.

Note You need to log in before you can comment on or make changes to this bug.