2727
2828package org .apache .hc .client5 .http .impl .async ;
2929
30- import java .util .Objects ;
3130import java .util .concurrent .ConcurrentLinkedQueue ;
3231import java .util .concurrent .atomic .AtomicBoolean ;
3332import java .util .concurrent .atomic .AtomicInteger ;
3433
3534import org .apache .hc .core5 .annotation .Internal ;
3635import 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