From 1353a51a31f7e28ae28aa680233beb06ead7fb96 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Mon, 11 Jul 2016 20:39:46 -0400 Subject: [PATCH] tmf: Early-exit event search methods if monitor is cancelled Prevents from sending a request at all if the job is already cancelled when the methods get called. Fixes a spurious test failure, but also covers for the case where the job could be cancelled very quickly. Change-Id: I7dd17fd32663ad6985ad4572541e896e9173dc7d Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/77106 Reviewed-by: Matthew Khouzam Reviewed-by: Hudson CI --- .../eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java index 64b08c135c..a76e671d72 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTraceUtils.java @@ -205,6 +205,10 @@ public final class TmfTraceUtils { */ public static @Nullable ITmfEvent getNextEventMatching(ITmfTrace trace, long startRank, Predicate predicate, @Nullable IProgressMonitor monitor) { + if (monitor != null && monitor.isCanceled()) { + return null; + } + /* rank + 1 because we do not want to include the start event itself in the search */ EventMatchingRequest req = new EventMatchingRequest(startRank + 1, predicate, false); trace.sendRequest(req); @@ -244,6 +248,9 @@ public final class TmfTraceUtils { */ public static @Nullable ITmfEvent getPreviousEventMatching(ITmfTrace trace, long startRank, Predicate predicate, @Nullable IProgressMonitor monitor) { + if (monitor != null && monitor.isCanceled()) { + return null; + } /* * We are going to do a series of queries matching the trace's cache * size in length (which should minimize on-disk seeks), then iterate on -- 2.34.1