Skip to content

Commit 9a07ac0

Browse files
committed
Check if EMO time, cpu time, and receive time can fit in underlying type
1 parent 7e6d98b commit 9a07ac0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/projections/Tools/Timeline/EntryMethodObject.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,21 @@ protected EntryMethodObject(Data data, TimelineEvent tle,
128128

129129
beginTime = tle.BeginTime;
130130
elapsedTime = (int)(tle.EndTime - tle.BeginTime);
131+
if (tle.EndTime - tle.BeginTime != elapsedTime) {
132+
throw new IllegalArgumentException("Total time of entry method does not fit in type int");
133+
}
131134
// If the incoming RecvTime is 0, then it is invalid, so use MIN_VALUE to represent it in the offset
132135
recvTimeOffset = (tle.RecvTime == 0) ? Integer.MIN_VALUE : (int)(tle.RecvTime - tle.BeginTime);
136+
if (tle.RecvTime != 0 && tle.RecvTime - tle.BeginTime != recvTimeOffset) {
137+
throw new IllegalArgumentException("Difference between receive time and begin time for entry method does not fit in type int");
138+
}
133139
cpuBegin = tle.cpuBegin;
134-
cpuElapsed = (int)(tle.cpuEnd - tle.cpuBegin);
140+
if (cpuBegin > 0) {
141+
cpuElapsed = (int) (tle.cpuEnd - tle.cpuBegin);
142+
if (tle.cpuEnd - tle.cpuBegin != cpuElapsed) {
143+
throw new IllegalArgumentException("Total CPU time of entry method does not fit in type int");
144+
}
145+
}
135146
messages = msgs; // Set of TimelineMessage
136147
if (messages != null) {
137148
for (TimelineMessage msg : messages) {

0 commit comments

Comments
 (0)