tmf.xml: Fix condition ordering to avoid IndexOutOfBoundsException in FSM
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 4 May 2016 13:45:15 +0000 (09:45 -0400)
committerJean-Christian Kouame <jean-christian.kouame@ericsson.com>
Wed, 18 May 2016 17:58:10 +0000 (13:58 -0400)
If a scenario is not set as initial scenario, then no scenario is created and
the isNewScenarioAllowed method throws a IndexOutOfBoundsException. This patch
reorders the condition so it is first verified that the scenario count is more
than 0

Change-Id: I034e049ce6e1655fccbf6caf03978515285e9b73
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/72035
Reviewed-by: Hudson CI
Reviewed-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
Tested-by: Jean-Christian Kouame <jean-christian.kouame@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/model/TmfXmlFsm.java

index bef940004b852f9d2fb5833fe6301ee262ea138b..00e343d0e48fe7e70a39b1388723c4b07175b163 100644 (file)
@@ -302,7 +302,8 @@ public class TmfXmlFsm {
      * @return True if the start of a new scenario is allowed, false otherwise
      */
     public synchronized boolean isNewScenarioAllowed() {
-        return !fActiveScenariosList.get(fActiveScenariosList.size() - 1).getScenarioInfos().getStatus().equals(ScenarioStatusType.PENDING)
-                && fInstanceMultipleEnabled && fTotalScenarios > 0;
+        return fTotalScenarios > 0
+                && !fActiveScenariosList.get(fActiveScenariosList.size() - 1).getScenarioInfos().getStatus().equals(ScenarioStatusType.PENDING)
+                && fInstanceMultipleEnabled;
     }
 }
This page took 0.026471 seconds and 5 git commands to generate.