TMF: Bug 436576: Add null check on file field in XML state system module
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 4 Jun 2014 12:53:07 +0000 (08:53 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Fri, 6 Jun 2014 12:45:57 +0000 (08:45 -0400)
Change-Id: If3eca378edd8e050114c0b14eebc7f943e28e5c5
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/27929
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Hudson CI
(cherry picked from commit c3c922bd0a9373bae387ef9b8c80d90ed8a4db9c)
Reviewed-on: https://git.eclipse.org/r/27985

org.eclipse.linuxtools.tmf.analysis.xml.core/src/org/eclipse/linuxtools/tmf/analysis/xml/core/stateprovider/XmlStateSystemModule.java

index bb5932662320448716571287e4dd7a153d0351f1..66c8ee9a81ae3f84a12fee3634bfac709207f82e 100644 (file)
@@ -16,6 +16,7 @@ import java.util.List;
 
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlUtils;
 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
 import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemAnalysisModule;
@@ -29,7 +30,7 @@ import org.w3c.dom.Element;
  */
 public class XmlStateSystemModule extends TmfStateSystemAnalysisModule {
 
-    private IPath fXmlFile;
+    private @Nullable IPath fXmlFile;
 
     @Override
     protected StateSystemBackendType getBackendType() {
@@ -45,7 +46,11 @@ public class XmlStateSystemModule extends TmfStateSystemAnalysisModule {
     @Override
     public String getName() {
         String name = getId();
-        Element doc = XmlUtils.getElementInFile(fXmlFile.makeAbsolute().toString(), TmfXmlStrings.STATE_PROVIDER, getId());
+        IPath xmlFile = fXmlFile;
+        if (xmlFile == null) {
+            return name;
+        }
+        Element doc = XmlUtils.getElementInFile(xmlFile.makeAbsolute().toString(), TmfXmlStrings.STATE_PROVIDER, getId());
         /* Label may be available in XML header */
         List<Element> head = XmlUtils.getChildElements(doc, TmfXmlStrings.HEAD);
         if (head.size() == 1) {
This page took 0.028377 seconds and 5 git commands to generate.