From 42459d24193bd2c8e53a73362d439bb454c69706 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Mon, 29 Jul 2013 18:07:19 -0400 Subject: [PATCH] tmf: Make TmfTrace.buildStateSystem() return an IStatus 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 Reviewed-on: https://git.eclipse.org/r/14630 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann --- .../lttng2/kernel/core/trace/LttngKernelTrace.java | 14 +++++++++++--- .../linuxtools/tmf/core/trace/TmfTrace.java | 13 +++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java index cc72b09c10..41f15f8172 100644 --- a/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java +++ b/org.eclipse.linuxtools.lttng2.kernel.core/src/org/eclipse/linuxtools/lttng2/kernel/core/trace/LttngKernelTrace.java @@ -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; } } diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java index d139af810c..590d9d7f5d 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java @@ -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; } /** -- 2.34.1