import org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval;
import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
+import com.google.common.collect.Iterables;
+
/**
* The base class for all the types of nodes that go in the History Tree.
*
* If the offsets were right, the size of the Strings section should
* be == to the expected size
*/
- assert (curStringsEntryEndPos == fStringSectionOffset);
+ if (curStringsEntryEndPos != fStringSectionOffset) {
+ throw new IllegalStateException("Wrong size of Strings section: Actual: " + curStringsEntryEndPos + ", Expected: " + fStringSectionOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ }
/* Finally, write everything in the Buffer to disk */
buffer.flip();
int res = fc.write(buffer);
- assert (res == blockSize);
+ if (res != blockSize) {
+ throw new IllegalStateException("Wrong size of block written: Actual: " + res + ", Expected: " + blockSize); //$NON-NLS-1$ //$NON-NLS-2$
+ }
} finally {
fRwl.readLock().unlock();
public void closeThisNode(long endtime) {
fRwl.writeLock().lock();
try {
- assert (endtime >= fNodeStart);
+ /**
+ * FIXME: was assert (endtime >= fNodeStart); but that exception
+ * is reached with an empty node that has start time endtime + 1
+ */
+// if (endtime < fNodeStart) {
+// throw new IllegalArgumentException("Endtime " + endtime + " cannot be lower than start time " + fNodeStart);
+// }
if (!fIntervals.isEmpty()) {
/*
* EndTime > the one requested. Only need to check the last one
* since they are sorted
*/
- assert (endtime >= fIntervals.get(fIntervals.size() - 1).getEndTime());
+ if (endtime < Iterables.getLast(fIntervals).getEndTime()) {
+ throw new IllegalArgumentException("Closing end time should be greater than or equal to the end time of the intervals of this node"); //$NON-NLS-1$
+ }
}
fNodeEnd = endtime;
* No, this interval starts before the startTime of this node. We
* need to check recursively in parents if it can fit.
*/
- assert (indexOfNode >= 1);
tryInsertAtNode(interval, indexOfNode - 1);
return;
}
* Once we exit this loop, we should have found a children to follow. If
* we didn't, there's a problem.
*/
- assert (potentialNextSeqNb != currentNode.getSequenceNumber());
+ if (potentialNextSeqNb == currentNode.getSequenceNumber()) {
+ throw new IllegalStateException("No next child node found"); //$NON-NLS-1$
+ }
/*
* Since this code path is quite performance-critical, avoid iterating