tmf: Fix NPE in XmlPresentationProvider for undefined states
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Wed, 9 Mar 2016 16:18:16 +0000 (11:18 -0500)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Mon, 18 Apr 2016 18:38:49 +0000 (14:38 -0400)
A NullPointerException was caused when creating a state tooltip for
state values that are not defined in the XML definition.

This patch avoids the NPE in this case. The state tooltip won't be
shown when this happens.

Change-Id: I07ca75d7bb39d3479c225b4b144e1acc119eae3b
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/68072
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java

index f8985ad10ce35d3c573426b25c47076bf8e99016..cd7a8b27db6faddf25da2aeb24b1b3e296de0389 100644 (file)
@@ -13,8 +13,6 @@
 
 package org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -89,9 +87,11 @@ public class XmlPresentationProvider extends TimeGraphPresentationProvider {
             int value = tcEvent.getValue();
 
             if (entry.getType() == EntryDisplayType.DISPLAY) {
-                Integer index = checkNotNull(stateIndex.get(value));
-                String rgb = stateValues.get(index.intValue()).getStateString();
-                return rgb;
+                Integer index = stateIndex.get(value);
+                if (index != null) {
+                    String rgb = stateValues.get(index.intValue()).getStateString();
+                    return rgb;
+                }
             }
             return null;
         }
This page took 0.047941 seconds and 5 git commands to generate.