From af015d444de7ecb8c53a6f10f54a9249533f977d Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Wed, 23 Oct 2013 14:18:11 -0400 Subject: [PATCH] [LTTng] Fix BufferOverflowException batch importing LTTng UST trace Bug: 420203 Change-Id: Id0d793b39ad28c80fd04d61bcd2646b419656e9e Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/17699 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann Reviewed-by: Matthew Khouzam --- .../lttng2/ust/core/trace/LttngUstTrace.java | 12 +++++++++--- .../linuxtools/lttng2/ust/core/trace/Messages.java | 10 ++++++++++ .../lttng2/ust/core/trace/messages.properties | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/LttngUstTrace.java b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/LttngUstTrace.java index 9305dab40a..1dfa23f3a6 100644 --- a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/LttngUstTrace.java +++ b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/LttngUstTrace.java @@ -8,10 +8,13 @@ * * Contributors: * Matthew Khouzam - Initial API and implementation + * Marc-Andre Laperle - Handle BufferOverflowException (Bug 420203) **********************************************************************/ package org.eclipse.linuxtools.lttng2.ust.core.trace; +import java.nio.BufferOverflowException; + import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -43,10 +46,13 @@ public class LttngUstTrace extends CtfTmfTrace { try { temp = new CTFTrace(path); } catch (CTFReaderException e) { - status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); + return status; + } catch (NullPointerException e) { + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); return status; - } catch (NullPointerException e){ - status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); + } catch (final BufferOverflowException e) { + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_TraceReadError + ": " + Messages.LttngUstTrace_MalformedTrace); //$NON-NLS-1$ return status; } diff --git a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/Messages.java b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/Messages.java index f028b3a926..bd36c13aed 100644 --- a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/Messages.java +++ b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/Messages.java @@ -28,6 +28,16 @@ public class Messages extends NLS { */ public static String LttngUstTrace_DomainError; + /** + * Malformed trace (buffer overflow maybe?) + */ + public static String LttngUstTrace_MalformedTrace; + + /** + * Trace read error + */ + public static String LttngUstTrace_TraceReadError; + static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/messages.properties b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/messages.properties index 8f044d7346..d170bb9a2f 100644 --- a/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/messages.properties +++ b/org.eclipse.linuxtools.lttng2.ust.core/src/org/eclipse/linuxtools/lttng2/ust/core/trace/messages.properties @@ -11,3 +11,5 @@ ############################################################################### LttngUstTrace_DomainError=Domain mismatch, the environment should be 'ust'. +LttngUstTrace_MalformedTrace=Buffer overflow exception, trace is malformed +LttngUstTrace_TraceReadError=Lttng UST trace read error \ No newline at end of file -- 2.34.1