tmf: Bug 489971: Premature processing of payload in custom parser
Change-Id: Ia4fdfb23352df5761e370e198f3d986eb5cfc9df
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/69059
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java
index e06481f..ae36c6a 100644
--- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java
+++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEvent.java
@@ -187,6 +187,18 @@
// ------------------------------------------------------------------------
/**
+ * Get this event's content value.
+ * <p>
+ * This does not process the payload data and is therefore safe to call in
+ * the middle of parsing an event.
+ *
+ * @return the event's content value.
+ */
+ Object getContentValue() {
+ return customEventContent.getValue();
+ }
+
+ /**
* Get the contents of an event table cell for this event's row.
*
* @param index
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTrace.java
index b8f4605..545c264 100644
--- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTrace.java
+++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTrace.java
@@ -378,7 +378,7 @@
}
}
}
- ((StringBuffer) event.getContent().getValue()).append("\n").append(line); //$NON-NLS-1$
+ ((StringBuffer) event.getContentValue()).append("\n").append(line); //$NON-NLS-1$
}
}
rawPos = fFile.getFilePointer();
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java
index 8df4b1b..21bb0e8 100644
--- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java
+++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java
@@ -277,7 +277,7 @@
final Element element = parseElementBuffer(elementBuffer);
event = extractEvent(element, fRecordInputElement);
- ((StringBuffer) event.getContent().getValue()).append(elementBuffer);
+ ((StringBuffer) event.getContentValue()).append(elementBuffer);
long rawPos = fFile.getFilePointer();
String line = fFile.getNextLine();
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomTxtIndexTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomTxtIndexTest.java
index 82a5419..fcd1cd4 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomTxtIndexTest.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/trace/CustomTxtIndexTest.java
@@ -57,6 +57,10 @@
SimpleDateFormat f = new SimpleDateFormat(TIMESTAMP_FORMAT);
String eventStr = f.format(new Date(i)) + " hello world\n";
writer.write(eventStr);
+ int extra = i % 3;
+ for (int j = 0; j < extra; j++) {
+ writer.write("extra line\n");
+ }
}
}
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.tests/tracesets/txt/testTxtDefinition.xml b/tmf/org.eclipse.tracecompass.tmf.ui.tests/tracesets/txt/testTxtDefinition.xml
index ee2f9cb..b2af6b4 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui.tests/tracesets/txt/testTxtDefinition.xml
+++ b/tmf/org.eclipse.tracecompass.tmf.ui.tests/tracesets/txt/testTxtDefinition.xml
@@ -7,6 +7,11 @@
<RegEx>(\S*\s\S*) (.*\S)</RegEx>
<InputData action="0" format="dd/MM/yyyy HH:mm:ss:SSS" name="Time Stamp"/>
<InputData action="0" format="" name="Message"/>
+<InputLine>
+<Cardinality max="2147483647" min="0"/>
+<RegEx>(.*\S)</RegEx>
+<InputData action="2" name="Message"/>
+</InputLine>
</InputLine>
<OutputColumn name="Time Stamp"/>
<OutputColumn name="Message"/>