Program: 85829
Project: 85829
Buggy source:
private ListenableFuture<Object> downloadDependenciesInternal(final Transaction tx,final Object marker,final List<Transaction> results){
  final SettableFuture<Object> resultFuture=SettableFuture.create();
  final Sha256Hash rootTxHash=tx.getHash();
  Set<Transaction> dependencies=new CopyOnWriteArraySet<Transaction>();
  Set<Sha256Hash> needToRequest=new CopyOnWriteArraySet<Sha256Hash>();
  for (  TransactionInput input : tx.getInputs()) {
    Sha256Hash hash=input.getOutpoint().getHash();
    Transaction dep=memoryPool.get(hash);
    if (dep == null) {
      needToRequest.add(hash);
    }
 else {
      dependencies.add(dep);
    }
  }
  results.addAll(dependencies);
  lock.lock();
  try {
    List<ListenableFuture<Transaction>> futures=Lists.newArrayList();
    GetDataMessage getdata=new GetDataMessage(params);
    final long nonce=(long)(Math.random() * Long.MAX_VALUE);
    for (    Sha256Hash hash : needToRequest) {
      getdata.addTransaction(hash);
      GetDataRequest req=new GetDataRequest();
      req.hash=hash;
      req.future=SettableFuture.create();
      if (!isNotFoundMessageSupported()) {
        req.nonce=nonce;
      }
      futures.add(req.future);
      getDataFutures.add(req);
    }
    for (    Transaction dep : dependencies) {
      futures.add(Futures.immediateFuture(dep));
    }
    ListenableFuture<List<Transaction>> successful=Futures.successfulAsList(futures);
    Futures.addCallback(successful,new FutureCallback<List<Transaction>>(){
      public void onSuccess(      List<Transaction> transactions){
        List<ListenableFuture<Object>> childFutures=Lists.newLinkedList();
        for (        Transaction tx : transactions) {
          if (tx == null)           continue;
          log.info("String_Node_Str",new Object[]{vAddress,rootTxHash,tx.getHashAsString()});
          results.add(tx);
          childFutures.add(downloadDependenciesInternal(tx,marker,results));
        }
        if (childFutures.size() == 0) {
          resultFuture.set(marker);
        }
 else {
          Futures.addCallback(Futures.successfulAsList(childFutures),new FutureCallback<List<Object>>(){
            public void onSuccess(            List<Object> objects){
              resultFuture.set(marker);
            }
            public void onFailure(            Throwable throwable){
              resultFuture.setException(throwable);
            }
          }
);
        }
      }
      public void onFailure(      Throwable throwable){
        resultFuture.setException(throwable);
      }
    }
);
    sendMessage(getdata);
    if (!isNotFoundMessageSupported()) {
      ping(nonce).addListener(new Runnable(){
        public void run(){
          for (          GetDataRequest req : getDataFutures) {
            if (req.nonce == nonce) {
              req.future.cancel(true);
              getDataFutures.remove(req);
              break;
            }
          }
        }
      }
,MoreExecutors.sameThreadExecutor());
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",tx.getHash());
    resultFuture.setException(e);
    return resultFuture;
  }
 finally {
    lock.unlock();
  }
  return resultFuture;
}

Fixed version (ground truth):
private ListenableFuture<Object> downloadDependenciesInternal(final Transaction tx,final Object marker,final List<Transaction> results){
  final SettableFuture<Object> resultFuture=SettableFuture.create();
  final Sha256Hash rootTxHash=tx.getHash();
  Set<Transaction> dependencies=new CopyOnWriteArraySet<Transaction>();
  Set<Sha256Hash> needToRequest=new CopyOnWriteArraySet<Sha256Hash>();
  for (  TransactionInput input : tx.getInputs()) {
    Sha256Hash hash=input.getOutpoint().getHash();
    Transaction dep=memoryPool.get(hash);
    if (dep == null) {
      needToRequest.add(hash);
    }
 else {
      dependencies.add(dep);
    }
  }
  results.addAll(dependencies);
  lock.lock();
  try {
    List<ListenableFuture<Transaction>> futures=Lists.newArrayList();
    GetDataMessage getdata=new GetDataMessage(params);
    final long nonce=(long)(Math.random() * Long.MAX_VALUE);
    if (needToRequest.size() > 1)     log.info("String_Node_Str",needToRequest.size());
    for (    Sha256Hash hash : needToRequest) {
      getdata.addTransaction(hash);
      GetDataRequest req=new GetDataRequest();
      req.hash=hash;
      req.future=SettableFuture.create();
      if (!isNotFoundMessageSupported()) {
        req.nonce=nonce;
      }
      futures.add(req.future);
      getDataFutures.add(req);
    }
    for (    Transaction dep : dependencies) {
      futures.add(Futures.immediateFuture(dep));
    }
    ListenableFuture<List<Transaction>> successful=Futures.successfulAsList(futures);
    Futures.addCallback(successful,new FutureCallback<List<Transaction>>(){
      public void onSuccess(      List<Transaction> transactions){
        List<ListenableFuture<Object>> childFutures=Lists.newLinkedList();
        for (        Transaction tx : transactions) {
          if (tx == null)           continue;
          log.info("String_Node_Str",new Object[]{vAddress,rootTxHash,tx.getHashAsString()});
          results.add(tx);
          childFutures.add(downloadDependenciesInternal(tx,marker,results));
        }
        if (childFutures.size() == 0) {
          resultFuture.set(marker);
        }
 else {
          Futures.addCallback(Futures.successfulAsList(childFutures),new FutureCallback<List<Object>>(){
            public void onSuccess(            List<Object> objects){
              resultFuture.set(marker);
            }
            public void onFailure(            Throwable throwable){
              resultFuture.setException(throwable);
            }
          }
);
        }
      }
      public void onFailure(      Throwable throwable){
        resultFuture.setException(throwable);
      }
    }
);
    sendMessage(getdata);
    if (!isNotFoundMessageSupported()) {
      log.info("String_Node_Str",this,nonce);
      ping(nonce).addListener(new Runnable(){
        public void run(){
          for (          GetDataRequest req : getDataFutures) {
            if (req.nonce == nonce) {
              log.info("String_Node_Str",this,req.hash);
              req.future.cancel(true);
              getDataFutures.remove(req);
            }
          }
        }
      }
,MoreExecutors.sameThreadExecutor());
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",this,tx.getHash());
    resultFuture.setException(e);
    return resultFuture;
  }
 finally {
    lock.unlock();
  }
  return resultFuture;
}