Skip to content

Commit 8aadb51

Browse files
authored
Merge pull request #23580 from njr-11/23579-unexpected-delay
test of unit conversions did not allow for rounding up
2 parents 9249ef7 + e2d6719 commit 8aadb51

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

dev/com.ibm.ws.concurrent_fat/test-applications/concurrentSpec/src/fat/concurrent/spec/app/EEConcurrencyTestServlet.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9389,27 +9389,27 @@ public void testUnitConversions() throws Exception {
93899389
ScheduledFuture<?> future1 = schedxsvcDefault.schedule((Runnable) new CounterTask(), 1000000, TimeUnit.DAYS);
93909390
try {
93919391
long days = future1.getDelay(TimeUnit.DAYS);
9392-
if (days != 106751l) // maximum possible due to limiations of java.util.concurrent.TimeUnit
9392+
if (days > 1000000l || days < 106751l) // maximum possible due to limitations of java.util.concurrent.TimeUnit
93939393
throw new Exception("Task1: Unexpected delay in days: " + days);
93949394

93959395
long hours = future1.getDelay(TimeUnit.HOURS);
9396-
if (hours != 2562047l)
9396+
if (hours > 24000000l || hours < 2562047l)
93979397
throw new Exception("Task1: Unexpected delay in hours: " + hours);
93989398

93999399
long minutes = future1.getDelay(TimeUnit.MINUTES);
9400-
if (minutes != 153722867l)
9400+
if (minutes > 1440000000l || minutes < 153722867l)
94019401
throw new Exception("Task1: Unexpected delay in minutes: " + minutes);
94029402

94039403
long seconds = future1.getDelay(TimeUnit.SECONDS); // expecting 9223372036, but allow for additional time that might have elapsed
9404-
if (seconds < 9223372030l || seconds > 9223372036l)
9404+
if (seconds > 86400000000l || seconds < 9223372030l)
94059405
throw new Exception("Task1: Unexpected delay in seconds: " + seconds);
94069406

94079407
long millis = future1.getDelay(TimeUnit.MILLISECONDS);
9408-
if (millis < 9223372030000l || millis > 9223372038000l)
9408+
if (millis > 86400000000000l || millis < 9223372030000l)
94099409
throw new Exception("Task1: Unexpected delay in milliseconds: " + millis);
94109410

94119411
long micros = future1.getDelay(TimeUnit.MICROSECONDS);
9412-
if (micros < 9223372030000000l || micros > 9223372038000000l)
9412+
if (micros > 86400000000000000l || micros < 9223372030000000l)
94139413
throw new Exception("Task1: Unexpected delay in microseconds: " + micros);
94149414

94159415
long nanos = future1.getDelay(TimeUnit.NANOSECONDS);
@@ -9424,15 +9424,15 @@ public void testUnitConversions() throws Exception {
94249424
throw new Exception("Task2: Unexpected delay in seconds: " + days);
94259425

94269426
minutes = future2.getDelay(TimeUnit.MINUTES);
9427-
if (minutes != 153722866l)
9427+
if (minutes > 153722867l || minutes < 153722866l) // allow for rounding up or down
94289428
throw new Exception("Task2: Unexpected delay in minutes: " + minutes);
94299429

94309430
hours = future2.getDelay(TimeUnit.HOURS);
9431-
if (hours != 2562047l)
9431+
if (hours > 2562048l || hours < 2562047l)
94329432
throw new Exception("Task2: Unexpected delay in hours: " + hours);
94339433

94349434
days = future1.getDelay(TimeUnit.DAYS);
9435-
if (days != 106751l)
9435+
if (days > 106752l || days < 106751l)
94369436
throw new Exception("Task1: Unexpected delay in days: " + days);
94379437

94389438
int result = future1.compareTo(future2);
@@ -9446,7 +9446,7 @@ public void testUnitConversions() throws Exception {
94469446
}
94479447

94489448
long days = future1.getDelay(TimeUnit.DAYS);
9449-
if (days != 106751l)
9449+
if (days > 106752l || days < 106751l)
94509450
throw new Exception("Delay should remain unchanged after canceling task in order to be consistent with java.util.concurrent.ScheduledThreadPoolExecutor. Instead: "
94519451
+ days);
94529452

0 commit comments

Comments
 (0)