Skip to content

Commit 369c6db

Browse files
committed
Use Args instead
1 parent 7f79f72 commit 369c6db

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/SharedRequestExecutionQueue.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
package org.apache.hc.client5.http.impl.async;
2929

30-
import java.util.Objects;
3130
import java.util.concurrent.ConcurrentLinkedQueue;
3231
import java.util.concurrent.atomic.AtomicBoolean;
3332
import java.util.concurrent.atomic.AtomicInteger;
3433

3534
import org.apache.hc.core5.annotation.Internal;
3635
import org.apache.hc.core5.concurrent.Cancellable;
36+
import org.apache.hc.core5.util.Args;
3737

3838
/**
3939
* Shared FIFO execution queue with a hard cap on concurrently executing tasks.
@@ -58,8 +58,8 @@ final class SharedRequestExecutionQueue {
5858
}
5959

6060
Cancellable enqueue(final Runnable task, final Runnable onCancel) {
61-
Objects.requireNonNull(task, "task");
62-
Objects.requireNonNull(onCancel, "onCancel");
61+
Args.notNull(task, "task");
62+
Args.notNull(onCancel, "onCancel");
6363

6464
final Entry entry = new Entry(task, onCancel);
6565
queue.add(entry);
@@ -81,7 +81,7 @@ private void drain() {
8181
while (inFlight.get() < maxConcurrent) {
8282
final Entry entry = queue.poll();
8383
if (entry == null) {
84-
return;
84+
break;
8585
}
8686
if (entry.isCancelled()) {
8787
continue;
@@ -99,6 +99,7 @@ private void drain() {
9999
}
100100
}
101101

102+
102103
private static final class Entry implements Cancellable {
103104

104105
private final Runnable task;

0 commit comments

Comments
 (0)