Program: 161648
Project: 161648
Buggy source:
/** 
 * An alternative to   {@link #blockTillAllComplete(Iterable)}, this provides the ability to know  when all futures are complete without blocking.  Unlike   {@link #blockTillAllComplete(Iterable)}, this requires that you provide a collection of   {@link ListenableFuture}'s.  But will return immediately, providing a new   {@link ListenableFuture} that will be called once all the provided futures have finished.  <p> The future returned will provide the result object once all provided futures have completed.   If any failures occured, they will not be represented in the returned future.  If that is  desired you should consider using  {@link #makeFailurePropagatingCompleteFuture(Iterable,Object)}, it has the same semantics as  this one except it will put the returned future into an error state if any of the provided  futures error.
 * @since 3.3.0
 * @param < T > type of result returned from the future
 * @param futures Collection of futures that must finish before returned future is satisfied
 * @param result Result to provide returned future once all futures complete
 * @return ListenableFuture which will be done once all futures provided are done
 */
@SuppressWarnings("String_Node_Str") public static <T>ListenableFuture<T> makeCompleteFuture(Iterable<? extends ListenableFuture<?>> futures,final T result){
  if (result == null) {
    return (ListenableFuture<T>)makeCompleteFuture(futures);
  }
  final EmptyFutureCollection efc=new EmptyFutureCollection(futures);
  if (efc.isDone()) {
    return immediateResultFuture(result);
  }
  final SettableListenableFuture<T> resultFuture=new CancelDelegateSettableListenableFuture<>(efc);
  efc.addCallback(new FutureCallback<Object>(){
    @Override public void handleResult(    Object ignored){
      resultFuture.setResult(result);
    }
    @Override public void handleFailure(    Throwable t){
      if (t instanceof CancellationException) {
      }
 else {
        resultFuture.setFailure(t);
      }
    }
  }
);
  return resultFuture;
}

Fixed version (ground truth):
/** 
 * An alternative to   {@link #blockTillAllComplete(Iterable)}, this provides the ability to know  when all futures are complete without blocking.  Unlike   {@link #blockTillAllComplete(Iterable)}, this requires that you provide a collection of   {@link ListenableFuture}'s.  But will return immediately, providing a new   {@link ListenableFuture} that will be called once all the provided futures have finished.  <p> The future returned will provide the result object once all provided futures have completed.   If any failures occured, they will not be represented in the returned future.  If that is  desired you should consider using  {@link #makeFailurePropagatingCompleteFuture(Iterable,Object)}, it has the same semantics as  this one except it will put the returned future into an error state if any of the provided  futures error.
 * @since 3.3.0
 * @param < T > type of result returned from the future
 * @param futures Collection of futures that must finish before returned future is satisfied
 * @param result Result to provide returned future once all futures complete
 * @return ListenableFuture which will be done once all futures provided are done
 */
@SuppressWarnings("String_Node_Str") public static <T>ListenableFuture<T> makeCompleteFuture(Iterable<? extends ListenableFuture<?>> futures,final T result){
  if (result == null) {
    return (ListenableFuture<T>)makeCompleteFuture(futures);
  }
  final EmptyFutureCollection efc=new EmptyFutureCollection(futures);
  if (efc.isDone()) {
    return immediateResultFuture(result);
  }
  final SettableListenableFuture<T> resultFuture=new CancelDelegateSettableListenableFuture<>(efc);
  efc.addCallback(new FutureCallback<Object>(){
    @Override public void handleResult(    Object ignored){
      resultFuture.setResult(result);
    }
    @Override public void handleFailure(    Throwable t){
      resultFuture.setFailure(t);
    }
  }
);
  return resultFuture;
}