From: Bernd Hufmann Date: Wed, 9 Mar 2016 16:18:16 +0000 (-0500) Subject: tmf: Fix NPE in XmlPresentationProvider for undefined states X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=5a016e25b641089d367ebf392172b92ff7ae8d89;p=deliverable%2Ftracecompass.git tmf: Fix NPE in XmlPresentationProvider for undefined states 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 Reviewed-on: https://git.eclipse.org/r/68072 Reviewed-by: Matthew Khouzam Reviewed-by: Hudson CI Tested-by: Matthew Khouzam --- diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java index f8985ad10c..cd7a8b27db 100644 --- a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlPresentationProvider.java @@ -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; }