tmf: Fix another TimeRangeException in TmfStateStatistics
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 17 Apr 2014 14:32:54 +0000 (10:32 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Thu, 24 Apr 2014 14:44:58 +0000 (10:44 -0400)
The exception occurs when the requested range is completely out of the
range of the state system, for example with an experiment containing two
traces that do not intersect.

Also changed exception handling so that StateSystemDisposedException is
ignored, and runtime exceptions are not caught.

Change-Id: Icbe242c7c875ebe7873b0ce88b09499444bc8e00
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/25212
Tested-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfStateStatistics.java

index d75aaa5dd110f99ac25b197e0e2b5e0ea8d013b5..9838592afcbf7051ba24e1868b1b59e9540b17b6 100644 (file)
@@ -21,8 +21,6 @@ import java.util.Map;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
 import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
-import org.eclipse.linuxtools.tmf.core.exceptions.StateValueTypeException;
-import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
 import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
 import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
 
@@ -146,10 +144,10 @@ public class TmfStateStatistics implements ITmfStatistics {
             final int quark = totalsStats.getQuarkAbsolute(Attributes.TOTAL);
             count= totalsStats.querySingleState(endTime, quark).getStateValue().unboxInt();
 
-        } catch (TimeRangeException e) {
+        } catch (StateSystemDisposedException e) {
             /* Assume there is no events for that range */
             return 0;
-        } catch (AttributeNotFoundException | StateValueTypeException | StateSystemDisposedException e) {
+        } catch (AttributeNotFoundException e) {
             e.printStackTrace();
         }
 
@@ -177,9 +175,9 @@ public class TmfStateStatistics implements ITmfStatistics {
                 map.put(curEventName, eventCount);
             }
 
-        } catch (TimeRangeException e) {
+        } catch (StateSystemDisposedException e) {
             /* Assume there is no events, nothing will be put in the map. */
-        } catch (AttributeNotFoundException | StateValueTypeException | StateSystemDisposedException e) {
+        } catch (AttributeNotFoundException e) {
             e.printStackTrace();
         }
         return map;
@@ -212,6 +210,11 @@ public class TmfStateStatistics implements ITmfStatistics {
          */
         long startTime = checkStartTime(start, typesStats);
         long endTime = checkEndTime(end, typesStats);
+        if (endTime < startTime) {
+            /* The start/end times do not intersect this state system range.
+             * Return the empty map. */
+            return map;
+        }
 
         try {
             /* Get the list of quarks, one for each even type in the database */
@@ -261,14 +264,8 @@ public class TmfStateStatistics implements ITmfStatistics {
                 }
             }
 
-        } catch (TimeRangeException | StateSystemDisposedException e) {
+        } catch (StateSystemDisposedException e) {
             /* Assume there is no (more) events, nothing will be put in the map. */
-        } catch (StateValueTypeException e) {
-            /*
-             * This exception type would show a logic problem however,
-             * so they should not happen.
-             */
-            throw new IllegalStateException();
         }
         return map;
     }
@@ -287,9 +284,9 @@ public class TmfStateStatistics implements ITmfStatistics {
             long count = totalsStats.querySingleState(ts, quark).getStateValue().unboxInt();
             return count;
 
-        } catch (TimeRangeException e) {
-            /* Assume there is no events for that range */
-        } catch (AttributeNotFoundException | StateValueTypeException | StateSystemDisposedException e) {
+        } catch (StateSystemDisposedException e) {
+            /* Assume there is no (more) events, nothing will be put in the map. */
+        } catch (AttributeNotFoundException e) {
             e.printStackTrace();
         }
 
This page took 0.02717 seconds and 5 git commands to generate.