tmf: Make TmfTrace.buildStateSystem() return an IStatus
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 29 Jul 2013 22:07:19 +0000 (18:07 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 30 Jul 2013 17:17:56 +0000 (13:17 -0400)
This removes the need for the SuppressWarnings("unused"), since
every implementation can now return an IStatus (or simply a
Status.OK_STATUS if everything went fine) instead of throwing
an exception.

Change-Id: I23f644988420bbfb4a26caf5e0099c4e26e37072
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/14630
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java

index cc72b09c109100b4a8cf7cab872da0045ee76f69..41f15f81721c5601735d289ac2bcc76e3bb8ffee 100644 (file)
@@ -87,8 +87,11 @@ public class LttngKernelTrace extends CtfTmfTrace {
         return validStatus;
     }
 
+    /**
+     * @since 3.0
+     */
     @Override
-    protected void buildStateSystem() throws TmfTraceException {
+    protected IStatus buildStateSystem() {
         super.buildStateSystem();
 
         /* Build the state system specific to LTTng kernel traces */
@@ -96,8 +99,13 @@ public class LttngKernelTrace extends CtfTmfTrace {
         final File htFile = new File(directory + HISTORY_TREE_FILE_NAME);
         final ITmfStateProvider htInput = new LttngKernelStateProvider(this);
 
-        ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
-        fStateSystems.put(STATE_ID, ss);
+        try {
+            ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, htInput, false);
+            fStateSystems.put(STATE_ID, ss);
+        } catch (TmfTraceException e) {
+            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());
+        }
+        return Status.OK_STATUS;
     }
 
 }
index d139af810cd561f41f80e384fef869a16c784683..590d9d7f5df85d1fa3c703552b7644042105e2b8 100644 (file)
@@ -22,6 +22,8 @@ import java.util.Map;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
@@ -265,17 +267,16 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      * Suppressing the warning, because the 'throws' will usually happen in
      * sub-classes.
      *
-     * @throws TmfTraceException
-     *             If there is a problem during the build
-     * @since 2.0
+     * @return An IStatus indicating if the state system could be build
+     *         successfully or not.
+     * @since 3.0
      */
-    @SuppressWarnings("unused")
-    protected void buildStateSystem() throws TmfTraceException {
+    protected IStatus buildStateSystem() {
         /*
          * Nothing is done in the base implementation, please specify
          * how/if to register a new state system in derived classes.
          */
-        return;
+        return Status.OK_STATUS;
     }
 
     /**
This page took 0.027799 seconds and 5 git commands to generate.