Bug 1031200 - Error rendering metrics chart; Attempt to compare null values in queryResourceMetrics
Summary: Error rendering metrics chart; Attempt to compare null values in queryResourc...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Core UI
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: RHQ 4.10
Assignee: Lukas Krejci
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-15 21:23 UTC by Elias Ross
Modified: 2014-04-23 12:31 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-04-23 12:31:07 UTC
Embargoed:


Attachments (Terms of Use)

Description Elias Ross 2013-11-15 21:23:10 UTC
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 23:02:32 UTC
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 17:06:30 UTC
Thanks for the BZ Elias.

commit 3cbe934a3b7f986ca816744bb2578bdfbad23e56
Author: Lukas Krejci <lkrejci>
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 17:08:29 UTC
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 12:31:07 UTC
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.