File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
src/java.base/share/classes/java/util/concurrent Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 3535
3636package java .util .concurrent ;
3737
38+ import org .jspecify .annotations .NullMarked ;
39+ import org .jspecify .annotations .Nullable ;
40+
3841/**
3942 * A service that decouples the production of new asynchronous tasks
4043 * from the consumption of the results of completed tasks. Producers
6265 *
6366 * @since 1.5
6467 */
65- public interface CompletionService <V > {
68+ @ NullMarked
69+ public interface CompletionService <V extends @ Nullable Object > {
6670 /**
6771 * Submits a value-returning task for execution and returns a Future
6872 * representing the pending results of the task. Upon completion,
@@ -108,7 +112,7 @@ public interface CompletionService<V> {
108112 * @return the Future representing the next completed task, or
109113 * {@code null} if none are present
110114 */
111- Future <V > poll ();
115+ @ Nullable Future <V > poll ();
112116
113117 /**
114118 * Retrieves and removes the Future representing the next
@@ -124,5 +128,5 @@ public interface CompletionService<V> {
124128 * before one is present
125129 * @throws InterruptedException if interrupted while waiting
126130 */
127- Future <V > poll (long timeout , TimeUnit unit ) throws InterruptedException ;
131+ @ Nullable Future <V > poll (long timeout , TimeUnit unit ) throws InterruptedException ;
128132}
Original file line number Diff line number Diff line change 3535
3636package java .util .concurrent ;
3737
38+ import org .jspecify .annotations .NullMarked ;
39+ import org .jspecify .annotations .Nullable ;
40+
3841/**
3942 * A {@link CompletionService} that uses a supplied {@link Executor}
4043 * to execute tasks. This class arranges that submitted tasks are,
102105 *
103106 * @since 1.5
104107 */
105- public class ExecutorCompletionService <V > implements CompletionService <V > {
108+ @ NullMarked
109+ public class ExecutorCompletionService <V extends @ Nullable Object > implements CompletionService <V > {
106110 private final Executor executor ;
107111 private final AbstractExecutorService aes ;
108112 private final BlockingQueue <Future <V >> completionQueue ;
@@ -202,11 +206,11 @@ public Future<V> take() throws InterruptedException {
202206 return completionQueue .take ();
203207 }
204208
205- public Future <V > poll () {
209+ public @ Nullable Future <V > poll () {
206210 return completionQueue .poll ();
207211 }
208212
209- public Future <V > poll (long timeout , TimeUnit unit )
213+ public @ Nullable Future <V > poll (long timeout , TimeUnit unit )
210214 throws InterruptedException {
211215 return completionQueue .poll (timeout , unit );
212216 }
You can’t perform that action at this time.
0 commit comments