Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2015-01-07 22:34:35 +0000
committerMarc-Andre Laperle2015-01-09 20:07:17 +0000
commit195210be4d39f938542dd5c454892223aca0128a (patch)
tree45eed67c96a3987e6633690156143797be6288e0
parent7399469d5950f2ece206265ba9395b4eed84d157 (diff)
downloadorg.eclipse.linuxtools-195210be4d39f938542dd5c454892223aca0128a.tar.gz
org.eclipse.linuxtools-195210be4d39f938542dd5c454892223aca0128a.tar.xz
org.eclipse.linuxtools-195210be4d39f938542dd5c454892223aca0128a.zip
tmf: Add missing test files in jars and make XmlAnalysisModuleSource safer
If the analysis.xml.ui.tests binary plugin is present in an installation, XmlAnalysisModuleSource looks for an inexistant file and throws a NPE. In this patch, the missing files are included and XmlAnalysisModuleSource is made safer in case an extension throws an exception. Change-Id: If1cc6478d61bf4a73047246c59ba45cb347411e5 Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/39156 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/build.properties3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui.tests/build.properties3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java41
3 files changed, 33 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/build.properties b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/build.properties
index b92be859f2..d08b64947d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/build.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.core.tests/build.properties
@@ -14,7 +14,8 @@ source.. = src/,\
output.. = bin/
bin.includes = META-INF/,\
.,\
- about.html
+ about.html,\
+ test_xml_files/
src.includes = about.html
additional.bundles = org.eclipse.jdt.annotation
jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
diff --git a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui.tests/build.properties b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui.tests/build.properties
index d41c0d9c2f..5480447948 100644
--- a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui.tests/build.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui.tests/build.properties
@@ -14,5 +14,6 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
about.html,\
- plugin.xml
+ plugin.xml,\
+ test_xml_files/
src.includes = about.html
diff --git a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java
index 05e5f6a974..c7c1558208 100644
--- a/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java
+++ b/lttng/org.eclipse.linuxtools.tmf.analysis.xml.ui/src/org/eclipse/linuxtools/tmf/analysis/xml/ui/module/XmlAnalysisModuleSource.java
@@ -13,6 +13,7 @@
package org.eclipse.linuxtools.tmf.analysis.xml.ui.module;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@@ -25,7 +26,9 @@ import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.Activator;
import org.eclipse.linuxtools.tmf.analysis.xml.core.module.XmlUtils;
import org.eclipse.linuxtools.tmf.analysis.xml.core.stateprovider.TmfXmlStrings;
@@ -103,20 +106,34 @@ public class XmlAnalysisModuleSource implements IAnalysisModuleSource {
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_XML_BUILTIN_ID);
for (IConfigurationElement element : elements) {
if (element.getName().equals(XML_FILE_ELEMENT)) {
- String filename = element.getAttribute(XML_FILE_ATTRIB);
- String name = element.getContributor().getName();
- if (name != null) {
- Bundle bundle = Platform.getBundle(name);
- if (bundle != null) {
- try {
- URL xmlUrl = bundle.getResource(filename);
- URL locatedURL = FileLocator.toFileURL(xmlUrl);
- processFile(new File(locatedURL.getFile()));
- } catch (IOException e) {
- /* ignore */
+ final String filename = element.getAttribute(XML_FILE_ATTRIB);
+ final String name = element.getContributor().getName();
+ // Run this in a safe runner in case there is an exception
+ // (IOException, FileNotFoundException, NPE, etc).
+ // This makes sure other extensions are not prevented from
+ // working if one is faulty.
+ SafeRunner.run(new ISafeRunnable() {
+
+ @Override
+ public void run() throws Exception {
+ if (name != null) {
+ Bundle bundle = Platform.getBundle(name);
+ if (bundle != null) {
+ URL xmlUrl = bundle.getResource(filename);
+ if (xmlUrl == null) {
+ throw new FileNotFoundException(filename);
+ }
+ URL locatedURL = FileLocator.toFileURL(xmlUrl);
+ processFile(new File(locatedURL.getFile()));
+ }
}
}
- }
+
+ @Override
+ public void handleException(Throwable exception) {
+ // Handled sufficiently in SafeRunner
+ }
+ });
}
}
}

Back to the top