tmf : Fix potential null pointer dereference in XmlUtils
authorJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Wed, 10 Feb 2016 20:37:12 +0000 (15:37 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 12 Feb 2016 19:26:52 +0000 (14:26 -0500)
There is a possible null pointer exception that would have happened if
I/O errors occur.

Change-Id: I89bde3aaf4d82c71fb46fe6b4e9720603ad481bf
Signed-off-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/66347
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/XmlUtils.java

index 9fe69a03d79ab8d281adb0da94599b46899d855a..175e9235f6addf3de66af91e192107696feffcdd 100644 (file)
@@ -157,12 +157,16 @@ public class XmlUtils {
 
         Map<String, File> fileMap = new HashMap<>();
         if ((folder.isDirectory() && folder.exists())) {
-            File[] listOfFiles = getXmlFilesPath().toFile().listFiles();
-            for (File file : listOfFiles) {
-                IPath path = new Path(file.getName());
-                if (path.getFileExtension().equals(XML_EXTENSION)) {
-                    fileMap.put(file.getName(), file);
+            File[] listOfFiles = folder.listFiles();
+            if (listOfFiles != null) {
+                for (File file : listOfFiles) {
+                    IPath path = new Path(file.getName());
+                    if (path.getFileExtension().equals(XML_EXTENSION)) {
+                        fileMap.put(file.getName(), file);
+                    }
                 }
+            } else {
+                Activator.logError("I/O error occured while accessing files in folder " + folder.getPath()); //$NON-NLS-1$
             }
         }
         return Collections.unmodifiableMap(fileMap);
This page took 0.024878 seconds and 5 git commands to generate.