Skip to content

Commit 96d52c1

Browse files
committed
Account for unit test rare failure seen IRL
1 parent 5472f68 commit 96d52c1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ public void testBorrowObjectFairness() throws Exception {
10751075
}
10761076
}
10771077

1078-
@Test/* maxWaitMillis x2 + padding */
1078+
@Test
10791079
@Timeout(value = 1200, unit = TimeUnit.MILLISECONDS)
10801080
public void testBorrowObjectOverrideMaxWaitLarge() throws Exception {
10811081
try (final GenericObjectPool<String> pool = new GenericObjectPool<>(createSlowObjectFactory(60_000))) {
@@ -1092,13 +1092,13 @@ public void testBorrowObjectOverrideMaxWaitLarge() throws Exception {
10921092
"borrowObject must fail quickly due to timeout parameter"));
10931093
final long millis = d.toMillis();
10941094
final long nanos = d.toNanos();
1095-
assertTrue(nanos > 0, () -> "borrowObject(Duration) argument not respected: " + nanos);
1095+
assertTrue(nanos >= 0, () -> "borrowObject(Duration) argument not respected: " + nanos);
10961096
assertTrue(millis >= 0, () -> "borrowObject(Duration) argument not respected: " + millis); // not > 0 to account for spurious waits
10971097
assertTrue(millis < 50, () -> "borrowObject(Duration) argument not respected: " + millis);
10981098
}
10991099
}
11001100

1101-
@Test/* maxWaitMillis x2 + padding */
1101+
@Test
11021102
@Timeout(value = 1200, unit = TimeUnit.MILLISECONDS)
11031103
public void testBorrowObjectOverrideMaxWaitSmall() throws Exception {
11041104
try (final GenericObjectPool<String> pool = new GenericObjectPool<>(createSlowObjectFactory(60_000))) {
@@ -1115,7 +1115,7 @@ public void testBorrowObjectOverrideMaxWaitSmall() throws Exception {
11151115
"borrowObject must fail slowly due to timeout parameter"));
11161116
final long millis = d.toMillis();
11171117
final long nanos = d.toNanos();
1118-
assertTrue(nanos > 0, () -> "borrowObject(Duration) argument not respected: " + nanos);
1118+
assertTrue(nanos >= 0, () -> "borrowObject(Duration) argument not respected: " + nanos);
11191119
assertTrue(millis >= 0, () -> "borrowObject(Duration) argument not respected: " + millis); // not > 0 to account for spurious waits
11201120
assertTrue(millis < 600, () -> "borrowObject(Duration) argument not respected: " + millis);
11211121
assertTrue(millis > 490, () -> "borrowObject(Duration) argument not respected: " + millis);

0 commit comments

Comments
 (0)