Skip to content

Commit cfef056

Browse files
committed
Fis SpotBugs concern.
1 parent 2c80db1 commit cfef056

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

driver-core/src/main/com/mongodb/internal/async/AsyncTrampoline.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.mongodb.assertions.Assertions;
2121
import com.mongodb.lang.Nullable;
2222

23+
import static com.mongodb.assertions.Assertions.assertNotNull;
24+
2325
/**
2426
* A trampoline that converts recursive callback invocations into an iterative loop,
2527
* preventing stack overflow in async loops.
@@ -66,8 +68,10 @@ public static void run(final Runnable work) {
6668
try {
6769
work.run();
6870
// drain any re-entrant work iteratively
69-
while (bounce.hasWork()) {
70-
bounce.runNext();
71+
while (bounce.work != null) {
72+
Runnable workToRun = bounce.work;
73+
bounce.work = null;
74+
workToRun.run();
7175
}
7276
} finally {
7377
TRAMPOLINE.remove();
@@ -91,16 +95,5 @@ void enqueue(final Runnable task) {
9195
}
9296
this.work = task;
9397
}
94-
95-
boolean hasWork() {
96-
return work != null;
97-
}
98-
99-
void runNext() {
100-
Runnable task = this.work;
101-
this.work = null;
102-
Assertions.assertNotNull(task);
103-
task.run();
104-
}
10598
}
106-
}
99+
}

0 commit comments

Comments
 (0)