Bug 407474 - Exceptions thrown when opening/closing trace with no event
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 7 May 2013 22:27:40 +0000 (18:27 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 9 May 2013 17:44:49 +0000 (13:44 -0400)
Change-Id: I54f618692fba19c07eec436227b1428cddc3a87d
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/12604
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>

org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/Messages.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/messages.properties

index 615efdb773083042771e4cf3d4cf9302977a8b14..2aa6afb30def602c8935c73ce5b99ae5d0b6662a 100644 (file)
@@ -195,6 +195,11 @@ public class CTFTraceReader {
      * lower next event timestamp.
      */
     private void populateStreamInputReaderHeap() {
+        if (this.streamInputReaders.isEmpty()) {
+            this.prio = new PriorityQueue<StreamInputReader>();
+            return;
+        }
+
         /*
          * Create the priority queue with a size twice as bigger as the number
          * of reader in order to avoid constant resizing.
index 4273276badc733135a97e7f9576814ed707937b1..8375eaad91823b82245dcdf243a0b74ded389797 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
 import org.eclipse.linuxtools.internal.tmf.core.Activator;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
@@ -133,11 +134,18 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser {
         IStatus validTrace = Status.OK_STATUS;
         try {
             final CTFTrace temp = new CTFTrace(path);
-            boolean valid = temp.majortIsSet(); // random test
-            temp.dispose();
-            if (!valid) {
+            if (!temp.majortIsSet()) {
                 validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_MajorNotSet);
+            } else {
+                CTFTraceReader ctfTraceReader = new CTFTraceReader(temp);
+                if (!ctfTraceReader.hasMoreEvents()) {
+                    // TODO: This will need an additional check when we support live traces
+                    // because having no event is valid for a live trace
+                    validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_NoEvent);
+                }
+                ctfTraceReader.dispose();
             }
+            temp.dispose();
         } catch (final CTFReaderException e) {
             validTrace = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError +": " + e.toString()); //$NON-NLS-1$
         }
index fa6d2969bbb45904835fb1bee60f2416c323df46..654a6ce72424b8b3e93a79636a82200aec0cab35 100644 (file)
@@ -29,6 +29,9 @@ public class Messages extends NLS {
     /** Reading error */
     public static String CtfTmfTrace_ReadingError;
 
+    /** No event */
+    public static String CtfTmfTrace_NoEvent;
+
     static {
         // initialize resource bundle
         NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index fe43860fa5da42560fd17b41df5d74edbfc1f12f..5fe42dca0ca173cdc9ef8dea5702c4ae85f7591c 100644 (file)
@@ -12,3 +12,4 @@
 
 CtfTmfTrace_MajorNotSet=Major version number not set
 CtfTmfTrace_ReadingError=Reading error
+CtfTmfTrace_NoEvent=Trace has no events
\ No newline at end of file
This page took 0.028739 seconds and 5 git commands to generate.