Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2014-06-05 18:09:02 +0000
committerPatrick Tasse2014-06-06 13:52:41 +0000
commita4c5fa74959575b88a228f0cbb221f507f1544d8 (patch)
treeeef09aba5bd64974f6722664572635ce5411663d
parent266a2dda5e14171ef9b58a0359db71f92cb80758 (diff)
downloadorg.eclipse.linuxtools-a4c5fa74959575b88a228f0cbb221f507f1544d8.tar.gz
org.eclipse.linuxtools-a4c5fa74959575b88a228f0cbb221f507f1544d8.tar.xz
org.eclipse.linuxtools-a4c5fa74959575b88a228f0cbb221f507f1544d8.zip
tmf: Bug 436738: NPE after deleting default custom parser
- Reload the default custom parser (if it exists) after deleting any custom parser - Add null checks when getting a trace type helper from a trace type id Change-Id: If2b947ff6ce18371e9fdbe5a68f02a1b650fc27a Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/28067 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com> (cherry picked from commit ed74d892ad2dfaafd64c43b6a1b619d402780438) Reviewed-on: https://git.eclipse.org/r/28075
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTraceDefinition.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomXmlTraceDefinition.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/importtrace/ImportTraceContentProvider.java21
6 files changed, 22 insertions, 9 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java
index 264368d686..1a414d18ac 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/analysis/AnalysisModuleHelperTest.java
@@ -237,6 +237,7 @@ public class AnalysisModuleHelperTest {
Iterable<Class<? extends ITmfTrace>> traceTypes = fReqModule.getValidTraceTypes();
for (Class<? extends ITmfTrace> traceType : traceTypes) {
assertTrue(fReqModule.appliesToTraceType(traceType));
+ assertNotNull(traceTypeHelper);
assertEquals(traceTypeHelper.getTraceClass(), traceType);
traceTypeCount++;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTraceDefinition.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTraceDefinition.java
index e65aca6cb5..44362fbf1e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTraceDefinition.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomTxtTraceDefinition.java
@@ -908,6 +908,8 @@ public class CustomTxtTraceDefinition extends CustomTraceDefinition {
}
TmfTraceType.removeCustomTraceType(TmfTraceType.CUSTOM_TXT_CATEGORY, definitionName);
+ // Check if default definition needs to be reloaded
+ TmfTraceType.addCustomTraceType(TmfTraceType.CUSTOM_TXT_CATEGORY, definitionName);
} catch (ParserConfigurationException e) {
Activator.logError("Error deleting CustomTxtTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomXmlTraceDefinition.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomXmlTraceDefinition.java
index 44da114ea6..8da8916959 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomXmlTraceDefinition.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomXmlTraceDefinition.java
@@ -801,6 +801,8 @@ public class CustomXmlTraceDefinition extends CustomTraceDefinition {
}
TmfTraceType.removeCustomTraceType(TmfTraceType.CUSTOM_XML_CATEGORY, definitionName);
+ // Check if default definition needs to be reloaded
+ TmfTraceType.addCustomTraceType(TmfTraceType.CUSTOM_XML_CATEGORY, definitionName);
} catch (ParserConfigurationException e) {
Activator.logError("Error deleteing CustomXmlTraceDefinition: definitionName=" + definitionName, e); //$NON-NLS-1$
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java
index 8f3fb53319..1f67af1660 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/project/model/TmfTraceType.java
@@ -487,7 +487,7 @@ public final class TmfTraceType {
public static boolean validate(String traceTypeName, String fileName) {
if (traceTypeName != null && !traceTypeName.isEmpty()) {
final TraceTypeHelper traceTypeHelper = TRACE_TYPES.get(traceTypeName);
- if (!traceTypeHelper.validate(fileName).isOK()) {
+ if (traceTypeHelper == null || !traceTypeHelper.validate(fileName).isOK()) {
return false;
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java
index e0d1723798..05095a1a6e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/SelectTraceTypeHandler.java
@@ -176,6 +176,9 @@ public class SelectTraceTypeHandler extends AbstractHandler {
throws CoreException {
TraceTypeHelper traceTypeHelper = TmfTraceType.getTraceType(traceType);
+ if (traceTypeHelper == null) {
+ return Status.CANCEL_STATUS;
+ }
final IStatus validateTraceType = traceTypeHelper.validate(element.getLocation().getPath());
if (!validateTraceType.isOK()) {
return validateTraceType;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/importtrace/ImportTraceContentProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/importtrace/ImportTraceContentProvider.java
index eb1898a1e8..6873662b49 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/importtrace/ImportTraceContentProvider.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/importtrace/ImportTraceContentProvider.java
@@ -24,6 +24,7 @@ import java.util.TreeSet;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
+import org.eclipse.linuxtools.tmf.core.project.model.TraceTypeHelper;
/**
* A helper class to show the trace types and files and names. it contains the
@@ -48,19 +49,23 @@ class ImportTraceContentProvider implements ITreeContentProvider {
/**
* Add a trace candidate to display
*
- * @param category
- * the category of the trace
+ * @param traceTypeId
+ * the trace type id of the trace
* @param traceToOpen
* the trace file.
*/
- public synchronized void addCandidate(String category, File traceToOpen) {
- fTraceTypes.put(TmfTraceType.getTraceType(category).getName(), category);
- if (!fTraceFiles.containsKey(category)) {
- fTraceFiles.put(category, new TreeSet<FileAndName>());
+ public synchronized void addCandidate(String traceTypeId, File traceToOpen) {
+ TraceTypeHelper traceTypeHelper = TmfTraceType.getTraceType(traceTypeId);
+ if (traceTypeHelper == null) {
+ return;
+ }
+ fTraceTypes.put(traceTypeHelper.getName(), traceTypeId);
+ if (!fTraceFiles.containsKey(traceTypeId)) {
+ fTraceFiles.put(traceTypeId, new TreeSet<FileAndName>());
}
final FileAndName traceFile = new FileAndName(traceToOpen, traceToOpen.getName());
- traceFile.setTraceTypeId(category);
- final Set<FileAndName> categorySet = fTraceFiles.get(category);
+ traceFile.setTraceTypeId(traceTypeId);
+ final Set<FileAndName> categorySet = fTraceFiles.get(traceTypeId);
categorySet.add(traceFile);
}

Back to the top