Skip to content

Commit 1a56895

Browse files
committed
Test: Use the standard timeout in TestCommandListener
1 parent dcc1572 commit 1a56895

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import java.util.concurrent.locks.Lock;
4444
import java.util.concurrent.locks.ReentrantLock;
4545

46+
import static com.mongodb.ClusterFixture.TIMEOUT;
4647
import static java.util.Collections.emptyList;
4748
import static org.junit.Assert.assertEquals;
4849
import static org.junit.Assert.assertNull;
@@ -130,7 +131,7 @@ public List<CommandEvent> getCommandStartedEvents() {
130131
private List<CommandEvent> getCommandStartedEvents(final int maxEvents) {
131132
lock.lock();
132133
try {
133-
List<CommandEvent> commandStartedEvents = new ArrayList<CommandEvent>();
134+
List<CommandEvent> commandStartedEvents = new ArrayList<>();
134135
for (CommandEvent cur : getEvents()) {
135136
if (cur instanceof CommandStartedEvent) {
136137
commandStartedEvents.add(cur);
@@ -150,7 +151,7 @@ public List<CommandEvent> waitForStartedEvents(final int numEvents) {
150151
try {
151152
while (!hasCompletedEvents(numEvents)) {
152153
try {
153-
if (!commandCompletedCondition.await(10, TimeUnit.SECONDS)) {
154+
if (!commandCompletedCondition.await(TIMEOUT, TimeUnit.SECONDS)) {
154155
throw new MongoTimeoutException("Timeout waiting for event");
155156
}
156157
} catch (InterruptedException e) {
@@ -168,7 +169,7 @@ public void waitForFirstCommandCompletion() {
168169
try {
169170
while (!hasCompletedEvents(1)) {
170171
try {
171-
if (!commandCompletedCondition.await(10, TimeUnit.SECONDS)) {
172+
if (!commandCompletedCondition.await(TIMEOUT, TimeUnit.SECONDS)) {
172173
throw new MongoTimeoutException("Timeout waiting for event");
173174
}
174175
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)