This is an automated email from the ASF dual-hosted git repository.

mattisonchao pushed a commit to branch branch-2.9
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.9 by this push:
     new f81b2421c6a [improve][common] Use `Collection` to instead of `List` 
parameter type (#15329)
f81b2421c6a is described below

commit f81b2421c6a982992833db36749d09cecef960bc
Author: Qiang Zhao <[email protected]>
AuthorDate: Tue Apr 26 22:11:35 2022 +0800

    [improve][common] Use `Collection` to instead of `List` parameter type 
(#15329)
    
    ### Motivation
    
    We can use `Collection` instead of `List` parameter type in `FutureUtil` 
for better compatibility.
    For example when we need to use the values of `Map`:
    
    ```java
    FutureUtil.waitForAll(map.values());
    ```
    ### Modifications
    
    - Use `Collection` instead of `List` parameter type.
    
    (cherry picked from commit 0c694cfdc9b11f915f1da86260ad3655c2e99a35)
---
 .../main/java/org/apache/pulsar/common/util/FutureUtil.java  | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java 
b/pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java
index dac204db98e..d35a6b405b2 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/util/FutureUtil.java
@@ -20,7 +20,6 @@ package org.apache.pulsar.common.util;
 
 import java.time.Duration;
 import java.util.Collection;
-import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletionException;
@@ -39,17 +38,17 @@ import java.util.stream.Collectors;
 public class FutureUtil {
 
     /**
-     * Return a future that represents the completion of the futures in the 
provided list.
+     * Return a future that represents the completion of the futures in the 
provided Collection.
      *
      * @param futures futures to wait for
      * @return a new CompletableFuture that is completed when all of the given 
CompletableFutures complete
      */
-    public static CompletableFuture<Void> waitForAll(List<? extends 
CompletableFuture<?>> futures) {
+    public static CompletableFuture<Void> waitForAll(Collection<? extends 
CompletableFuture<?>> futures) {
         return CompletableFuture.allOf(futures.toArray(new 
CompletableFuture[0]));
     }
 
     /**
-     * Return a future that represents the completion of any future in the 
provided list.
+     * Return a future that represents the completion of any future in the 
provided Collection.
      *
      * @param futures futures to wait any
      * @return a new CompletableFuture that is completed when any of the given 
CompletableFutures complete
@@ -102,14 +101,15 @@ public class FutureUtil {
 
 
     /**
-     * Return a future that represents the completion of the futures in the 
provided list.
+     * Return a future that represents the completion of the futures in the 
provided Collection.
      * The future will support {@link CompletableFuture#cancel(boolean)}. It 
will cancel
      * all unfinished futures when the future gets cancelled.
      *
      * @param futures futures to wait for
      * @return a new CompletableFuture that is completed when all of the given 
CompletableFutures complete
      */
-    public static CompletableFuture<Void> waitForAllAndSupportCancel(List<? 
extends CompletableFuture<?>> futures) {
+    public static CompletableFuture<Void> waitForAllAndSupportCancel(
+                                                    Collection<? extends 
CompletableFuture<?>> futures) {
         CompletableFuture[] futuresArray = futures.toArray(new 
CompletableFuture[0]);
         CompletableFuture<Void> combinedFuture = 
CompletableFuture.allOf(futuresArray);
         whenCancelledOrTimedOut(combinedFuture, () -> {

Reply via email to