chenyuzhi459 commented on a change in pull request #10027:
URL: https://github.com/apache/druid/pull/10027#discussion_r441927349
##########
File path: core/src/main/java/org/apache/druid/common/guava/GuavaUtils.java
##########
@@ -77,4 +79,24 @@ public static Long tryParseLong(@Nullable String string)
}
return arg1;
}
+
+ /**
+ * Cancel futures manually, because sometime we can't cancel all futures in
{@link com.google.common.util.concurrent.Futures.CombinedFuture}
+ * automatically. Especially when we call {@link
com.google.common.util.concurrent.Futures#allAsList(Iterable)} to create a
batch of
+ * future.
+ * @param futures The futures that we want to cancel
+ * @param <T> The result type returned by this Future's {@code get} method
+ */
+ public static <T, F extends Future<T>> void cancelAll(List<F> futures){
+ if(futures == null || futures.isEmpty()){
+ return;
+ }
+ futures.forEach(f -> {
+ try {
+ f.cancel(true);
+ } catch (Throwable t){
+ //do nothing and continue the loop.
Review comment:
Well, I think it's great that we shouldn't chomp throwables. But the
method that `AbstractFuture.cancel` probably throws exceptions because it will
execute future's listeners which is called by `ExecutionList.executeListener`.
And `ExecutionList.executeListener` only catch `RuntimeException`, thus i think
we should log exceptions.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]