diff options
author | Loïc Prieur-Drevon | 2017-07-20 13:15:44 +0000 |
---|---|---|
committer | Loic Prieur-Drevon | 2017-07-21 16:52:38 +0000 |
commit | 01de2ac9c816f9fb14e53653dabfa639a830362f (patch) | |
tree | d12f647f8620793d59ba1f8f44d35b0cc8f757a3 | |
parent | 2819f58c20379b0b56e590368cc459f625fc2c8f (diff) | |
download | org.eclipse.tracecompass-01de2ac9c816f9fb14e53653dabfa639a830362f.tar.gz org.eclipse.tracecompass-01de2ac9c816f9fb14e53653dabfa639a830362f.tar.xz org.eclipse.tracecompass-01de2ac9c816f9fb14e53653dabfa639a830362f.zip |
ss: 2D query fixes
Return an empty iterable instead of throwing an exception when
the collection of quarks is empty.
Fix a null pointer exception in the iterables.
Change-Id: Id8c3d71396943bd796211c9c68aba7640050c132
Signed-off-by: Loïc Prieur-Drevon <loic.prieurdrevon@gmail.com>
Reviewed-on: https://git.eclipse.org/r/101647
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
2 files changed, 12 insertions, 1 deletions
diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java index 4351314005..464fb30aec 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/StateSystem.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -626,6 +627,9 @@ public class StateSystem implements ITmfStateSystemBuilder { if (isDisposed) { throw new StateSystemDisposedException(); } + if (times.isEmpty()) { + return Collections.emptyList(); + } TimeRangeCondition timeCondition = TimeRangeCondition.forDiscreteRange(times); return query2D(quarks, timeCondition); @@ -648,6 +652,10 @@ public class StateSystem implements ITmfStateSystemBuilder { throw new TimeRangeException(); } + if (quarks.isEmpty()) { + return Collections.emptyList(); + } + IntegerRangeCondition quarkCondition = IntegerRangeCondition.forDiscreteRange(quarks); if (quarkCondition.min() < 0 || quarkCondition.max() >= getNbAttributes()) { throw new IndexOutOfBoundsException(); diff --git a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTreeBackend.java b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTreeBackend.java index d4ed26d2f4..02d96d9f8f 100644 --- a/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTreeBackend.java +++ b/statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTreeBackend.java @@ -384,7 +384,10 @@ public class HistoryTreeBackend implements IStateHistoryBackend { /* Recursive call to flatten children */ return flatten(getSHT().readNode(seqNum), quarks, subTimes); } catch (ClosedChannelException e) { - return null; + /** + * return node since we were able to read it. + */ + return Collections.singleton(node); } }); /* BFS */ |