nus-yam/ex-repair huggingface dataset:
Program: 85715
Project: 85715
Buggy source:
private static void informListenerForNewTransactions(Block block,NewBlockType newBlockType,@Nullable List<Sha256Hash> filteredTxHashList,@Nullable Map<Sha256Hash,Transaction> filteredTxn,StoredBlock newStoredBlock,boolean first,BlockChainListener listener,Set<Transaction> falsePositives) throws VerificationException {
  if (block.transactions != null) {
    sendTransactionsToListener(newStoredBlock,newBlockType,listener,0,block.transactions,!first,falsePositives);
  }
 else   if (filteredTxHashList != null) {
    checkNotNull(filteredTxn);
    int relativityOffset=0;
    for (    Sha256Hash hash : filteredTxHashList) {
      Transaction tx=filteredTxn.get(hash);
      if (tx != null)       sendTransactionsToListener(newStoredBlock,newBlockType,listener,relativityOffset,Arrays.asList(tx),!first,falsePositives);
 else       listener.notifyTransactionIsInBlock(hash,newStoredBlock,newBlockType,relativityOffset);
      relativityOffset++;
    }
  }
}

Fixed version (ground truth):
private static void informListenerForNewTransactions(Block block,NewBlockType newBlockType,@Nullable List<Sha256Hash> filteredTxHashList,@Nullable Map<Sha256Hash,Transaction> filteredTxn,StoredBlock newStoredBlock,boolean first,BlockChainListener listener,Set<Sha256Hash> falsePositives) throws VerificationException {
  if (block.transactions != null) {
    sendTransactionsToListener(newStoredBlock,newBlockType,listener,0,block.transactions,!first,falsePositives);
  }
 else   if (filteredTxHashList != null) {
    checkNotNull(filteredTxn);
    int relativityOffset=0;
    for (    Sha256Hash hash : filteredTxHashList) {
      Transaction tx=filteredTxn.get(hash);
      if (tx != null) {
        sendTransactionsToListener(newStoredBlock,newBlockType,listener,relativityOffset,Arrays.asList(tx),!first,falsePositives);
      }
 else {
        if (listener.notifyTransactionIsInBlock(hash,newStoredBlock,newBlockType,relativityOffset)) {
          falsePositives.remove(hash);
        }
      }
      relativityOffset++;
    }
  }
}
Program: 85716
Project: 85716
Buggy source:
@Override public void notifyTransactionIsInBlock(Sha256Hash txHash,StoredBlock block,BlockChain.NewBlockType blockType,int relativityOffset) throws VerificationException {
}

Fixed version (ground truth):
@Override public boolean notifyTransactionIsInBlock(Sha256Hash txHash,StoredBlock block,BlockChain.NewBlockType blockType,int relativityOffset) throws VerificationException {
  return false;
}
Program: 85717
Project: 85717
Buggy source:
/** 
 * <p>Called by the   {@link BlockChain} when we receive a new {@link FilteredBlock} that contains the giventransaction hash in its merkle tree.</p> <p>A transaction may be received multiple times if is included into blocks in parallel chains. The blockType parameter describes whether the containing block is on the main/best chain or whether it's on a presently inactive side chain.</p> <p>The relativityOffset parameter in this case is an arbitrary (meaningless) number, that is useful only when compared to the relativity count of another transaction received inside the same block. It is used to establish an ordering of transactions relative to one another.</p>
 */
void notifyTransactionIsInBlock(Sha256Hash txHash,StoredBlock block,BlockChain.NewBlockType blockType,int relativityOffset) throws VerificationException ;

Fixed version (ground truth):
/** 
 * <p>Called by the   {@link BlockChain} when we receive a new {@link FilteredBlock} that contains the giventransaction hash in its merkle tree.</p> <p>A transaction may be received multiple times if is included into blocks in parallel chains. The blockType parameter describes whether the containing block is on the main/best chain or whether it's on a presently inactive side chain.</p> <p>The relativityOffset parameter in this case is an arbitrary (meaningless) number, that is useful only when compared to the relativity count of another transaction received inside the same block. It is used to establish an ordering of transactions relative to one another.</p> <p>This method should return false if the given tx hash isn't known about, e.g. because the the transaction was a Bloom false positive. If it was known about and stored, it should return true. The caller may need to know this to calculate the effective FP rate.</p>
 * @return whether the transaction is known about i.e. was considered relevant previously.
 */
boolean notifyTransactionIsInBlock(Sha256Hash txHash,StoredBlock block,BlockChain.NewBlockType blockType,int relativityOffset) throws VerificationException ;
Program: 85719
Project: 85719
Buggy source:
@Override public native void notifyTransactionIsInBlock(Sha256Hash txHash,StoredBlock block,BlockChain.NewBlockType blockType,int relativityOffset) throws VerificationException ;

Fixed version (ground truth):
@Override public native boolean notifyTransactionIsInBlock(Sha256Hash txHash,StoredBlock block,BlockChain.NewBlockType blockType,int relativityOffset) throws VerificationException ;
Program: 85721
Project: 85721
Buggy source:
public DeterministicKey derive(int child){
  return HDKeyDerivation.deriveChildKey(this,new ChildNumber(child,true));
}

Fixed version (ground truth):
/** 
 * Derives a child at the given index (note: not the "i" value).
 */
public DeterministicKey derive(int child){
  return HDKeyDerivation.deriveChildKey(this,new ChildNumber(child,true));
}
Program: 85722
Project: 85722
Buggy source:
@Override public DeterministicKeyChain toDecrypted(KeyParameter aesKey){
  checkState(getKeyCrypter() != null,"String_Node_Str");
  checkState(seed.isEncrypted());
  DeterministicSeed decSeed=seed.decrypt(getKeyCrypter(),aesKey);
  DeterministicKeyChain chain=new DeterministicKeyChain(decSeed);
  chain.lookaheadSize=lookaheadSize;
  for (  ECKey eckey : basicKeyChain.getKeys()) {
    DeterministicKey key=(DeterministicKey)eckey;
    if (key.getPath().size() != 3)     continue;
    checkState(key.isEncrypted());
    DeterministicKey parent=chain.hierarchy.get(checkNotNull(key.getParent()).getPath(),false,false);
    key=new DeterministicKey(key.getPubOnly(),parent);
    chain.hierarchy.putKey(key);
    chain.basicKeyChain.importKey(key);
  }
  chain.issuedExternalKeys=issuedExternalKeys;
  chain.issuedInternalKeys=issuedInternalKeys;
  return chain;
}

Fixed version (ground truth):
@Override public DeterministicKeyChain toDecrypted(KeyParameter aesKey){
  checkState(getKeyCrypter() != null,"String_Node_Str");
  checkState(seed.isEncrypted());
  DeterministicSeed decSeed=seed.decrypt(getKeyCrypter(),aesKey);
  DeterministicKeyChain chain=new DeterministicKeyChain(decSeed);
  if (!chain.getWatchingKey().getPubKeyPoint().equals(getWatchingKey().getPubKeyPoint()))   throw new KeyCrypterException("String_Node_Str");
  chain.lookaheadSize=lookaheadSize;
  for (  ECKey eckey : basicKeyChain.getKeys()) {
    DeterministicKey key=(DeterministicKey)eckey;
    if (key.getPath().size() != 3)     continue;
    checkState(key.isEncrypted());
    DeterministicKey parent=chain.hierarchy.get(checkNotNull(key.getParent()).getPath(),false,false);
    key=new DeterministicKey(key.getPubOnly(),parent);
    chain.hierarchy.putKey(key);
    chain.basicKeyChain.importKey(key);
  }
  chain.issuedExternalKeys=issuedExternalKeys;
  chain.issuedInternalKeys=issuedInternalKeys;
  return chain;
}
Program: 85723
Project: 85723
Buggy source:
@Test public void findKey() throws Exception {
  ECKey a=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  assertTrue(a instanceof DeterministicKey);
  ECKey b=group.freshKey(KeyChain.KeyPurpose.CHANGE);
  ECKey c=new ECKey();
  ECKey d=new ECKey();
  group.importKeys(c);
  assertTrue(group.hasKey(a));
  assertTrue(group.hasKey(b));
  assertTrue(group.hasKey(c));
  assertFalse(group.hasKey(d));
  ECKey result=group.findKeyFromPubKey(a.getPubKey());
  assertEquals(a,result);
  result=group.findKeyFromPubKey(b.getPubKey());
  assertEquals(b,result);
  result=group.findKeyFromPubHash(a.getPubKeyHash());
  assertEquals(a,result);
  result=group.findKeyFromPubHash(b.getPubKeyHash());
  assertEquals(b,result);
  result=group.findKeyFromPubKey(c.getPubKey());
  assertEquals(c,result);
  result=group.findKeyFromPubHash(c.getPubKeyHash());
  assertEquals(c,result);
  assertNull(group.findKeyFromPubKey(d.getPubKey()));
  assertNull(group.findKeyFromPubHash(d.getPubKeyHash()));
}

Fixed version (ground truth):
@Test public void findKey() throws Exception {
  ECKey a=group.freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  ECKey b=group.freshKey(KeyChain.KeyPurpose.CHANGE);
  ECKey c=new ECKey();
  ECKey d=new ECKey();
  group.importKeys(c);
  assertTrue(group.hasKey(a));
  assertTrue(group.hasKey(b));
  assertTrue(group.hasKey(c));
  assertFalse(group.hasKey(d));
  ECKey result=group.findKeyFromPubKey(a.getPubKey());
  assertEquals(a,result);
  result=group.findKeyFromPubKey(b.getPubKey());
  assertEquals(b,result);
  result=group.findKeyFromPubHash(a.getPubKeyHash());
  assertEquals(a,result);
  result=group.findKeyFromPubHash(b.getPubKeyHash());
  assertEquals(b,result);
  result=group.findKeyFromPubKey(c.getPubKey());
  assertEquals(c,result);
  result=group.findKeyFromPubHash(c.getPubKeyHash());
  assertEquals(c,result);
  assertNull(group.findKeyFromPubKey(d.getPubKey()));
  assertNull(group.findKeyFromPubHash(d.getPubKeyHash()));
}
Program: 85724
Project: 85724
Buggy source:
/** 
 * Returns the same key with the private part removed. May return the same instance.
 */
public DeterministicKey getPubOnly(){
  if (isPubKeyOnly())   return this;
  final DeterministicKey parentPub=getParent() == null ? null : getParent().getPubOnly();
  return new DeterministicKey(getPath(),getChainCode(),getPubKeyPoint(),null,parentPub);
}

Fixed version (ground truth):
/** 
 * Returns the same key with the private part removed. May return the same instance.
 */
public DeterministicKey getPubOnly(){
  if (isPubKeyOnly())   return this;
  return new DeterministicKey(getPath(),getChainCode(),getPubKeyPoint(),null,parent);
}
Program: 85725
Project: 85725
Buggy source:
static ImmutableList<ChildNumber> append(ImmutableList<ChildNumber> path,ChildNumber childNumber){
  return ImmutableList.<ChildNumber>builder().addAll(path).add(childNumber).build();
}

Fixed version (ground truth):
public static ImmutableList<ChildNumber> append(ImmutableList<ChildNumber> path,ChildNumber childNumber){
  return ImmutableList.<ChildNumber>builder().addAll(path).add(childNumber).build();
}
Program: 85726
Project: 85726
Buggy source:
/** 
 * Returns a freshly derived key that has not been returned by this method before. 
 */
@Override public DeterministicKey getKey(KeyPurpose purpose){
  lock.lock();
  try {
    DeterministicKey key;
    List<DeterministicKey> lookahead;
    if (purpose == KeyPurpose.RECEIVE_FUNDS) {
      issuedExternalKeys++;
      lookahead=maybeLookAhead(externalKey,issuedExternalKeys);
      key=HDKeyDerivation.deriveChildKey(externalKey,issuedExternalKeys - 1);
    }
 else     if (purpose == KeyPurpose.CHANGE) {
      issuedInternalKeys++;
      lookahead=maybeLookAhead(internalKey,issuedInternalKeys);
      key=HDKeyDerivation.deriveChildKey(internalKey,issuedInternalKeys - 1);
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + purpose);
    }
    basicKeyChain.importKeys(lookahead);
    return key;
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Returns a freshly derived key that has not been returned by this method before. 
 */
@Override public DeterministicKey getKey(KeyPurpose purpose){
  lock.lock();
  try {
    DeterministicKey key, parentKey;
    int index;
    if (purpose == KeyPurpose.RECEIVE_FUNDS) {
      index=++issuedExternalKeys;
      parentKey=externalKey;
    }
 else     if (purpose == KeyPurpose.CHANGE) {
      index=++issuedInternalKeys;
      parentKey=internalKey;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + purpose);
    }
    List<DeterministicKey> lookahead=maybeLookAhead(parentKey,index);
    basicKeyChain.importKeys(lookahead);
    key=hierarchy.get(HDUtils.append(parentKey.getPath(),new ChildNumber(index - 1,false)),false,false);
    return key;
  }
  finally {
    lock.unlock();
  }
}
Program: 85727
Project: 85727
Buggy source:
private List<DeterministicKey> maybeLookAhead(DeterministicKey parent,int issued){
  checkState(lock.isHeldByCurrentThread());
  final int numChildren=hierarchy.getNumChildren(parent.getPath());
  int needed=issued + getLookaheadSize() - numChildren;
  checkState(needed >= 0,"String_Node_Str" + needed);
  List<DeterministicKey> result=new ArrayList<DeterministicKey>(needed);
  if (needed == 0)   return result;
  long now=System.currentTimeMillis();
  log.info("String_Node_Str",needed,parent.getPathAsString());
  for (int i=0; i < needed; i++) {
    DeterministicKey key=HDKeyDerivation.deriveChildKey(parent,numChildren + i);
    hierarchy.putKey(key);
    result.add(key);
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  return result;
}

Fixed version (ground truth):
private List<DeterministicKey> maybeLookAhead(DeterministicKey parent,int issued){
  checkState(lock.isHeldByCurrentThread());
  final int numChildren=hierarchy.getNumChildren(parent.getPath());
  int needed=issued + getLookaheadSize() - numChildren;
  checkState(needed >= 0,"String_Node_Str" + needed);
  List<DeterministicKey> result=new ArrayList<DeterministicKey>(needed);
  if (needed == 0)   return result;
  long now=System.currentTimeMillis();
  log.info("String_Node_Str",needed,parent.getPathAsString());
  for (int i=0; i < needed; i++) {
    DeterministicKey key=HDKeyDerivation.deriveChildKey(parent,numChildren + i);
    key=key.getPubOnly();
    hierarchy.putKey(key);
    result.add(key);
  }
  log.info("String_Node_Str",System.currentTimeMillis() - now);
  return result;
}
Program: 85729
Project: 85729
Buggy source:
private void createAndActivateNewHDChain(){
  final DeterministicKeyChain chain=new DeterministicKeyChain(new SecureRandom());
  if (lookaheadSize >= 0)   chain.setLookaheadSize(lookaheadSize);
  chains.add(chain);
}

Fixed version (ground truth):
private void createAndActivateNewHDChain(){
  final DeterministicKeyChain chain=new DeterministicKeyChain(new SecureRandom());
  for (  ListenerRegistration<KeyChainEventListener> registration : basic.getListeners())   chain.addEventListener(registration.listener,registration.executor);
  if (lookaheadSize >= 0)   chain.setLookaheadSize(lookaheadSize);
  chains.add(chain);
}
Program: 85730
Project: 85730
Buggy source:
@Override public long getEarliestKeyCreationTime(){
  return seed.getCreationTimeSeconds();
}

Fixed version (ground truth):
@Override public long getEarliestKeyCreationTime(){
  return seed != null ? seed.getCreationTimeSeconds() : Utils.currentTimeSeconds();
}
Program: 85731
Project: 85731
Buggy source:
@Test public void watchingChain() throws UnreadableWalletException {
  DeterministicKey key1=chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  DeterministicKey key2=chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  DeterministicKey key3=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  DeterministicKey key4=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  DeterministicKey watchingKey=chain.getWatchingKey();
  final String pub58=watchingKey.serializePubB58();
  assertEquals("String_Node_Str",pub58);
  watchingKey=DeterministicKey.deserializeB58(null,pub58);
  chain=new DeterministicKeyChain(watchingKey);
  chain.setLookaheadSize(10);
  assertEquals(key1.getPubKeyPoint(),chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKeyPoint());
  assertEquals(key2.getPubKeyPoint(),chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKeyPoint());
  final DeterministicKey key=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(key3.getPubKeyPoint(),key.getPubKeyPoint());
  try {
    key.sign(Sha256Hash.ZERO_HASH);
    fail();
  }
 catch (  ECKey.MissingPrivateKeyException e) {
  }
  List<Protos.Key> serialization=chain.serializeToProtobuf();
  checkSerialization(serialization,"String_Node_Str");
  chain=DeterministicKeyChain.fromProtobuf(serialization,null).get(0);
  final DeterministicKey rekey4=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(key4.getPubKeyPoint(),rekey4.getPubKeyPoint());
}

Fixed version (ground truth):
@Test public void watchingChain() throws UnreadableWalletException {
  Utils.setMockClock();
  DeterministicKey key1=chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  DeterministicKey key2=chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
  DeterministicKey key3=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  DeterministicKey key4=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  DeterministicKey watchingKey=chain.getWatchingKey();
  final String pub58=watchingKey.serializePubB58();
  assertEquals("String_Node_Str",pub58);
  watchingKey=DeterministicKey.deserializeB58(null,pub58);
  chain=new DeterministicKeyChain(watchingKey);
  assertEquals(Utils.currentTimeSeconds(),chain.getEarliestKeyCreationTime());
  chain.setLookaheadSize(10);
  assertEquals(key1.getPubKeyPoint(),chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKeyPoint());
  assertEquals(key2.getPubKeyPoint(),chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS).getPubKeyPoint());
  final DeterministicKey key=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(key3.getPubKeyPoint(),key.getPubKeyPoint());
  try {
    key.sign(Sha256Hash.ZERO_HASH);
    fail();
  }
 catch (  ECKey.MissingPrivateKeyException e) {
  }
  List<Protos.Key> serialization=chain.serializeToProtobuf();
  checkSerialization(serialization,"String_Node_Str");
  chain=DeterministicKeyChain.fromProtobuf(serialization,null).get(0);
  final DeterministicKey rekey4=chain.getKey(KeyChain.KeyPurpose.CHANGE);
  assertEquals(key4.getPubKeyPoint(),rekey4.getPubKeyPoint());
}
Program: 85732
Project: 85732
Buggy source:
@Test public void mnemonicCode() throws Exception {
  final List<String> words=chain.toMnemonicCode();
  assertEquals("String_Node_Str",Joiner.on("String_Node_Str").join(words));
  DeterministicSeed seed=new DeterministicSeed(words,checkNotNull(chain.getSeed()).getCreationTimeSeconds());
}

Fixed version (ground truth):
@Test public void mnemonicCode() throws Exception {
  final List<String> words=chain.toMnemonicCode();
  assertEquals("String_Node_Str",Joiner.on("String_Node_Str").join(words));
  new DeterministicSeed(words,checkNotNull(chain.getSeed()).getCreationTimeSeconds());
}
Program: 85733
Project: 85733
Buggy source:
/** 
 * @param iv
 * @param encryptedPrivateKeys
 */
public EncryptedPrivateKey(byte[] initialisationVector,byte[] encryptedPrivateKeys){
  setInitialisationVector(initialisationVector);
  setEncryptedPrivateBytes(encryptedPrivateKeys);
}

Fixed version (ground truth):
/** 
 * @param initialisationVector
 * @param encryptedPrivateKeys
 */
public EncryptedPrivateKey(byte[] initialisationVector,byte[] encryptedPrivateKeys){
  setInitialisationVector(initialisationVector);
  setEncryptedPrivateBytes(encryptedPrivateKeys);
}
Program: 85734
Project: 85734
Buggy source:
private Collection<InetSocketAddress> lookupAddresses(long timeoutValue,TimeUnit timeoutUnit,List<Circuit> circuits) throws InterruptedException {
  createThreadPool(circuits.size() * hostNames.length);
  try {
    List<ListenableFuture<Lookup>> lookupFutures=Lists.newArrayList();
    for (    final Circuit circuit : circuits) {
      for (      final String seed : hostNames) {
        lookupFutures.add(threadPool.submit(new Callable<Lookup>(){
          public Lookup call() throws Exception {
            return new Lookup(circuit.getFinalCircuitNode().getRouter(),lookup(circuit,seed));
          }
        }
));
      }
    }
    threadPool.awaitTermination(timeoutValue,timeoutUnit);
    for (    ListenableFuture<Lookup> future : lookupFutures) {
      if (!future.isDone()) {
        log.warn("String_Node_Str");
        future.cancel(true);
      }
    }
    try {
      List<Lookup> lookups=Futures.successfulAsList(lookupFutures).get();
      lookups.removeAll(Collections.singleton(null));
      Map<HexDigest,InetSocketAddress> lookupMap=Maps.newHashMap();
      for (      Lookup lookup : lookups) {
        InetSocketAddress address=new InetSocketAddress(lookup.address,netParams.getPort());
        lookupMap.put(lookup.router.getIdentityHash(),address);
      }
      return lookupMap.values();
    }
 catch (    ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
  finally {
    shutdownThreadPool();
  }
}

Fixed version (ground truth):
private Collection<InetSocketAddress> lookupAddresses(long timeoutValue,TimeUnit timeoutUnit,List<Circuit> circuits) throws InterruptedException {
  createThreadPool(circuits.size() * hostNames.length);
  try {
    List<ListenableFuture<Lookup>> lookupFutures=Lists.newArrayList();
    for (    final Circuit circuit : circuits) {
      for (      final String seed : hostNames) {
        lookupFutures.add(threadPool.submit(new Callable<Lookup>(){
          public Lookup call() throws Exception {
            return new Lookup(circuit.getFinalCircuitNode().getRouter(),lookup(circuit,seed));
          }
        }
));
      }
    }
    threadPool.awaitTermination(timeoutValue,timeoutUnit);
    for (    ListenableFuture<Lookup> future : lookupFutures) {
      if (!future.isDone()) {
        log.warn("String_Node_Str");
        future.cancel(true);
      }
    }
    try {
      List<Lookup> lookups=new ArrayList<Lookup>(Futures.successfulAsList(lookupFutures).get());
      lookups.removeAll(singleton(null));
      Map<HexDigest,InetSocketAddress> lookupMap=Maps.newHashMap();
      for (      Lookup lookup : lookups) {
        InetSocketAddress address=new InetSocketAddress(lookup.address,netParams.getPort());
        lookupMap.put(lookup.router.getIdentityHash(),address);
      }
      return lookupMap.values();
    }
 catch (    ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
  finally {
    shutdownThreadPool();
  }
}
Program: 85735
Project: 85735
Buggy source:
private List<Circuit> getCircuits(long timeoutValue,TimeUnit timeoutUnit,Set<Router> routers) throws InterruptedException {
  createThreadPool(routers.size());
  try {
    List<ListenableFuture<Circuit>> circuitFutures=Lists.newArrayList();
    for (    final Router router : routers) {
      circuitFutures.add(threadPool.submit(new Callable<Circuit>(){
        public Circuit call() throws Exception {
          return torClient.getCircuitManager().openInternalCircuitTo(Lists.newArrayList(router));
        }
      }
));
    }
    threadPool.awaitTermination(timeoutValue,timeoutUnit);
    for (    ListenableFuture<Circuit> future : circuitFutures) {
      if (!future.isDone()) {
        log.warn("String_Node_Str");
        future.cancel(true);
      }
    }
    List<Circuit> circuits;
    try {
      circuits=Futures.successfulAsList(circuitFutures).get();
      circuits.removeAll(Collections.singleton(null));
      return circuits;
    }
 catch (    ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
  finally {
    shutdownThreadPool();
  }
}

Fixed version (ground truth):
private List<Circuit> getCircuits(long timeoutValue,TimeUnit timeoutUnit,Set<Router> routers) throws InterruptedException {
  createThreadPool(routers.size());
  try {
    List<ListenableFuture<Circuit>> circuitFutures=Lists.newArrayList();
    for (    final Router router : routers) {
      circuitFutures.add(threadPool.submit(new Callable<Circuit>(){
        public Circuit call() throws Exception {
          return torClient.getCircuitManager().openInternalCircuitTo(Lists.newArrayList(router));
        }
      }
));
    }
    threadPool.awaitTermination(timeoutValue,timeoutUnit);
    for (    ListenableFuture<Circuit> future : circuitFutures) {
      if (!future.isDone()) {
        log.warn("String_Node_Str");
        future.cancel(true);
      }
    }
    try {
      List<Circuit> circuits=new ArrayList<Circuit>(Futures.successfulAsList(circuitFutures).get());
      circuits.removeAll(singleton(null));
      return circuits;
    }
 catch (    ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
  finally {
    shutdownThreadPool();
  }
}
Program: 85736
Project: 85736
Buggy source:
/** 
 * Create an encrypted private key with the keyCrypter and the AES key supplied. This method returns a new encrypted key and leaves the original unchanged. To be secure you need to clear the original, unencrypted private key bytes.
 * @param keyCrypter The keyCrypter that specifies exactly how the encrypted bytes are created.
 * @param aesKey The KeyParameter with the AES encryption key (usually constructed with keyCrypter#deriveKey and cached as it is slow to create).
 * @return encryptedKey
 */
public ECKey encrypt(KeyCrypter keyCrypter,KeyParameter aesKey) throws KeyCrypterException {
  Preconditions.checkNotNull(keyCrypter);
  final byte[] privKeyBytes=getPrivKeyBytes();
  checkState(privKeyBytes != null,"String_Node_Str");
  EncryptedPrivateKey encryptedPrivateKey=keyCrypter.encrypt(privKeyBytes,aesKey);
  return new ECKey(encryptedPrivateKey,getPubKey(),keyCrypter);
}

Fixed version (ground truth):
/** 
 * Create an encrypted private key with the keyCrypter and the AES key supplied. This method returns a new encrypted key and leaves the original unchanged. To be secure you need to clear the original, unencrypted private key bytes.
 * @param keyCrypter The keyCrypter that specifies exactly how the encrypted bytes are created.
 * @param aesKey The KeyParameter with the AES encryption key (usually constructed with keyCrypter#deriveKey and cached as it is slow to create).
 * @return encryptedKey
 */
public ECKey encrypt(KeyCrypter keyCrypter,KeyParameter aesKey) throws KeyCrypterException {
  Preconditions.checkNotNull(keyCrypter);
  final byte[] privKeyBytes=getPrivKeyBytes();
  checkState(privKeyBytes != null,"String_Node_Str");
  EncryptedPrivateKey encryptedPrivateKey=keyCrypter.encrypt(privKeyBytes,aesKey);
  ECKey result=new ECKey(encryptedPrivateKey,getPubKey(),keyCrypter);
  result.setCreationTimeSeconds(creationTimeSeconds);
  return result;
}
Program: 85737
Project: 85737
Buggy source:
/** 
 * Create a decrypted private key with the keyCrypter and AES key supplied. Note that if the aesKey is wrong, this has some chance of throwing KeyCrypterException due to the corrupted padding that will result, but it can also just yield a garbage key.
 * @param keyCrypter The keyCrypter that specifies exactly how the decrypted bytes are created.
 * @param aesKey The KeyParameter with the AES encryption key (usually constructed with keyCrypter#deriveKey and cached).
 * @return unencryptedKey
 */
public ECKey decrypt(KeyCrypter keyCrypter,KeyParameter aesKey) throws KeyCrypterException {
  Preconditions.checkNotNull(keyCrypter);
  if (this.keyCrypter != null && !this.keyCrypter.equals(keyCrypter)) {
    throw new KeyCrypterException("String_Node_Str");
  }
  byte[] unencryptedPrivateKey=keyCrypter.decrypt(encryptedPrivateKey,aesKey);
  ECKey key=new ECKey(new BigInteger(1,unencryptedPrivateKey),null,isCompressed());
  if (!Arrays.equals(key.getPubKey(),getPubKey()))   throw new KeyCrypterException("String_Node_Str");
  return key;
}

Fixed version (ground truth):
/** 
 * Create a decrypted private key with the keyCrypter and AES key supplied. Note that if the aesKey is wrong, this has some chance of throwing KeyCrypterException due to the corrupted padding that will result, but it can also just yield a garbage key.
 * @param keyCrypter The keyCrypter that specifies exactly how the decrypted bytes are created.
 * @param aesKey The KeyParameter with the AES encryption key (usually constructed with keyCrypter#deriveKey and cached).
 * @return unencryptedKey
 */
public ECKey decrypt(KeyCrypter keyCrypter,KeyParameter aesKey) throws KeyCrypterException {
  Preconditions.checkNotNull(keyCrypter);
  if (this.keyCrypter != null && !this.keyCrypter.equals(keyCrypter)) {
    throw new KeyCrypterException("String_Node_Str");
  }
  byte[] unencryptedPrivateKey=keyCrypter.decrypt(encryptedPrivateKey,aesKey);
  ECKey key=new ECKey(new BigInteger(1,unencryptedPrivateKey),null,isCompressed());
  if (!Arrays.equals(key.getPubKey(),getPubKey()))   throw new KeyCrypterException("String_Node_Str");
  key.setCreationTimeSeconds(creationTimeSeconds);
  return key;
}
Program: 85738
Project: 85738
Buggy source:
@Test public void testEncryptedCreate() throws Exception {
  ECKey unencryptedKey=new ECKey();
  byte[] originalPrivateKeyBytes=new byte[32];
  System.arraycopy(unencryptedKey.getPrivKeyBytes(),0,originalPrivateKeyBytes,0,32);
  log.info("String_Node_Str" + Utils.bytesToHexString(originalPrivateKeyBytes));
  EncryptedPrivateKey encryptedPrivateKey=keyCrypter.encrypt(unencryptedKey.getPrivKeyBytes(),keyCrypter.deriveKey(PASSWORD1));
  ECKey encryptedKey=new ECKey(encryptedPrivateKey,unencryptedKey.getPubKey(),keyCrypter);
  assertTrue("String_Node_Str",encryptedKey.isEncrypted());
  byte[] privateKeyBytes=encryptedKey.getPrivKeyBytes();
  if (privateKeyBytes != null) {
    for (int i=0; i < privateKeyBytes.length; i++) {
      assertEquals("String_Node_Str" + i + "String_Node_Str",0,privateKeyBytes[i]);
    }
  }
  ECKey rebornUnencryptedKey=encryptedKey.decrypt(keyCrypter,keyCrypter.deriveKey(PASSWORD1));
  assertTrue("String_Node_Str",!rebornUnencryptedKey.isEncrypted());
  privateKeyBytes=rebornUnencryptedKey.getPrivKeyBytes();
  log.info("String_Node_Str" + Utils.bytesToHexString(privateKeyBytes));
  for (int i=0; i < privateKeyBytes.length; i++) {
    assertEquals("String_Node_Str" + i + "String_Node_Str",originalPrivateKeyBytes[i],privateKeyBytes[i]);
  }
}

Fixed version (ground truth):
@Test public void testEncryptedCreate() throws Exception {
  ECKey unencryptedKey=new ECKey();
  byte[] originalPrivateKeyBytes=checkNotNull(unencryptedKey.getPrivKeyBytes());
  log.info("String_Node_Str" + Utils.bytesToHexString(originalPrivateKeyBytes));
  EncryptedPrivateKey encryptedPrivateKey=keyCrypter.encrypt(unencryptedKey.getPrivKeyBytes(),keyCrypter.deriveKey(PASSWORD1));
  ECKey encryptedKey=new ECKey(encryptedPrivateKey,unencryptedKey.getPubKey(),keyCrypter);
  assertTrue("String_Node_Str",encryptedKey.isEncrypted());
  byte[] privateKeyBytes=encryptedKey.getPrivKeyBytes();
  if (privateKeyBytes != null) {
    for (int i=0; i < privateKeyBytes.length; i++) {
      assertEquals("String_Node_Str" + i + "String_Node_Str",0,privateKeyBytes[i]);
    }
  }
  ECKey rebornUnencryptedKey=encryptedKey.decrypt(keyCrypter,keyCrypter.deriveKey(PASSWORD1));
  assertTrue(!rebornUnencryptedKey.isEncrypted());
  assertArrayEquals(originalPrivateKeyBytes,rebornUnencryptedKey.getPrivKeyBytes());
}
Program: 85739
Project: 85739
Buggy source:
@Test public void testUnencryptedCreate() throws Exception {
  ECKey unencryptedKey=new ECKey();
  assertTrue(!unencryptedKey.isEncrypted());
  byte[] originalPrivateKeyBytes=new byte[32];
  System.arraycopy(unencryptedKey.getPrivKeyBytes(),0,originalPrivateKeyBytes,0,32);
  log.info("String_Node_Str" + Utils.bytesToHexString(originalPrivateKeyBytes));
  ECKey encryptedKey=unencryptedKey.encrypt(keyCrypter,keyCrypter.deriveKey(PASSWORD1));
  assertTrue("String_Node_Str",encryptedKey.isEncrypted());
  byte[] privateKeyBytes=encryptedKey.getPrivKeyBytes();
  if (privateKeyBytes != null) {
    for (int i=0; i < privateKeyBytes.length; i++) {
      assertEquals("String_Node_Str" + i + "String_Node_Str",0,privateKeyBytes[i]);
    }
  }
  unencryptedKey=encryptedKey.decrypt(keyCrypter,keyCrypter.deriveKey(PASSWORD1));
  assertTrue("String_Node_Str",!unencryptedKey.isEncrypted());
  privateKeyBytes=unencryptedKey.getPrivKeyBytes();
  log.info("String_Node_Str" + Utils.bytesToHexString(privateKeyBytes));
  for (int i=0; i < privateKeyBytes.length; i++) {
    assertEquals("String_Node_Str" + i + "String_Node_Str",originalPrivateKeyBytes[i],privateKeyBytes[i]);
  }
}

Fixed version (ground truth):
@Test public void testUnencryptedCreate() throws Exception {
  Utils.rollMockClock(0);
  ECKey key=new ECKey();
  long time=key.getCreationTimeSeconds();
  assertNotEquals(0,time);
  assertTrue(!key.isEncrypted());
  byte[] originalPrivateKeyBytes=key.getPrivKeyBytes();
  ECKey encryptedKey=key.encrypt(keyCrypter,keyCrypter.deriveKey(PASSWORD1));
  assertEquals(time,encryptedKey.getCreationTimeSeconds());
  assertTrue(encryptedKey.isEncrypted());
  assertNull(encryptedKey.getPrivKeyBytes());
  key=encryptedKey.decrypt(keyCrypter,keyCrypter.deriveKey(PASSWORD1));
  assertTrue(!key.isEncrypted());
  assertArrayEquals(originalPrivateKeyBytes,key.getPrivKeyBytes());
}
Program: 85740
Project: 85740
Buggy source:
/** 
 * Picks a peer from discovery and connects to it. If connection fails, picks another and tries again. 
 */
protected void connectToAnyPeer() throws PeerDiscoveryException {
  final State state=state();
  if (!(state == State.STARTING || state == State.RUNNING))   return;
  final PeerAddress addr;
  long nowMillis=Utils.currentTimeMillis();
  lock.lock();
  try {
    if (!haveReadyInactivePeer(nowMillis)) {
      discoverPeers();
      groupBackoff.trackSuccess();
      nowMillis=Utils.currentTimeMillis();
    }
    if (inactives.size() == 0) {
      log.debug("String_Node_Str");
      return;
    }
    addr=inactives.poll();
  }
  finally {
    lock.unlock();
  }
  long retryTime=Math.max(backoffMap.get(addr).getRetryTime(),groupBackoff.getRetryTime());
  if (retryTime > nowMillis) {
    Utils.sleep(retryTime - nowMillis);
  }
  connectTo(addr,false);
}

Fixed version (ground truth):
/** 
 * Picks a peer from discovery and connects to it. If connection fails, picks another and tries again. 
 */
protected void connectToAnyPeer() throws PeerDiscoveryException {
  final State state=state();
  if (!(state == State.STARTING || state == State.RUNNING))   return;
  PeerAddress addr=null;
  long nowMillis=Utils.currentTimeMillis();
  long retryTime=0;
  lock.lock();
  try {
    if (!haveReadyInactivePeer(nowMillis)) {
      discoverPeers();
      groupBackoff.trackSuccess();
      nowMillis=Utils.currentTimeMillis();
    }
    if (inactives.size() == 0) {
      log.debug("String_Node_Str");
      return;
    }
    addr=inactives.poll();
    retryTime=backoffMap.get(addr).getRetryTime();
  }
  finally {
    retryTime=Math.max(retryTime,groupBackoff.getRetryTime());
    lock.unlock();
    if (retryTime > nowMillis) {
      final long millis=retryTime - nowMillis;
      log.info("String_Node_Str",millis,addr == null ? "String_Node_Str" : "String_Node_Str" + addr);
      Utils.sleep(millis);
    }
  }
  checkNotNull(addr);
  connectTo(addr,false);
}
Program: 85741
Project: 85741
Buggy source:
protected void discoverPeers() throws PeerDiscoveryException {
  long start=System.currentTimeMillis();
  Set<PeerAddress> addressSet=Sets.newHashSet();
  for (  PeerDiscovery peerDiscovery : peerDiscoverers) {
    InetSocketAddress[] addresses;
    addresses=peerDiscovery.getPeers(5,TimeUnit.SECONDS);
    for (    InetSocketAddress address : addresses)     addressSet.add(new PeerAddress(address));
    if (addressSet.size() > 0)     break;
  }
  lock.lock();
  try {
    for (    PeerAddress address : addressSet) {
      addInactive(address);
    }
  }
  finally {
    lock.unlock();
  }
  log.info("String_Node_Str",System.currentTimeMillis() - start,addressSet.size());
}

Fixed version (ground truth):
protected void discoverPeers() throws PeerDiscoveryException {
  if (peerDiscoverers.isEmpty())   throw new PeerDiscoveryException("String_Node_Str");
  long start=System.currentTimeMillis();
  Set<PeerAddress> addressSet=Sets.newHashSet();
  for (  PeerDiscovery peerDiscovery : peerDiscoverers) {
    InetSocketAddress[] addresses;
    addresses=peerDiscovery.getPeers(5,TimeUnit.SECONDS);
    for (    InetSocketAddress address : addresses)     addressSet.add(new PeerAddress(address));
    if (addressSet.size() > 0)     break;
  }
  lock.lock();
  try {
    for (    PeerAddress address : addressSet) {
      addInactive(address);
    }
  }
  finally {
    lock.unlock();
  }
  log.info("String_Node_Str",System.currentTimeMillis() - start,addressSet.size());
}
Program: 85742
Project: 85742
Buggy source:
Ack(String memo){
  this.memo=memo;
}

Fixed version (ground truth):
Ack(@Nullable String memo){
  this.memo=memo;
}
Program: 85743
Project: 85743
Buggy source:
@Override public Ack call() throws Exception {
  HttpURLConnection connection=(HttpURLConnection)url.openConnection();
  connection.setRequestMethod("String_Node_Str");
  connection.setRequestProperty("String_Node_Str","String_Node_Str");
  connection.setRequestProperty("String_Node_Str","String_Node_Str");
  connection.setRequestProperty("String_Node_Str",Integer.toString(payment.getSerializedSize()));
  connection.setUseCaches(false);
  connection.setDoInput(true);
  connection.setDoOutput(true);
  DataOutputStream outStream=new DataOutputStream(connection.getOutputStream());
  payment.writeTo(outStream);
  outStream.flush();
  outStream.close();
  InputStream inStream=connection.getInputStream();
  Protos.PaymentACK.Builder paymentAckBuilder=Protos.PaymentACK.newBuilder().mergeFrom(inStream);
  Protos.PaymentACK paymentAck=paymentAckBuilder.build();
  String memo="String_Node_Str";
  if (paymentAck.hasMemo())   memo=paymentAck.getMemo();
  return new Ack(memo);
}

Fixed version (ground truth):
@Override public Ack call() throws Exception {
  HttpURLConnection connection=(HttpURLConnection)url.openConnection();
  connection.setRequestMethod("String_Node_Str");
  connection.setRequestProperty("String_Node_Str","String_Node_Str");
  connection.setRequestProperty("String_Node_Str","String_Node_Str");
  connection.setRequestProperty("String_Node_Str",Integer.toString(payment.getSerializedSize()));
  connection.setUseCaches(false);
  connection.setDoInput(true);
  connection.setDoOutput(true);
  DataOutputStream outStream=new DataOutputStream(connection.getOutputStream());
  payment.writeTo(outStream);
  outStream.flush();
  outStream.close();
  InputStream inStream=connection.getInputStream();
  Protos.PaymentACK.Builder paymentAckBuilder=Protos.PaymentACK.newBuilder().mergeFrom(inStream);
  Protos.PaymentACK paymentAck=paymentAckBuilder.build();
  String memo=null;
  if (paymentAck.hasMemo())   memo=paymentAck.getMemo();
  return new Ack(memo);
}
Program: 85744
Project: 85744
Buggy source:
/** 
 * Returns the memo included by the merchant in the payment request.
 */
public String getMemo(){
  return paymentDetails.getMemo();
}

Fixed version (ground truth):
/** 
 * Returns the memo included by the merchant in the payment request, or null if not found.
 */
@Nullable public String getMemo(){
  if (paymentDetails.hasMemo())   return paymentDetails.getMemo();
 else   return null;
}
Program: 85746
Project: 85746
Buggy source:
@VisibleForTesting protected ListenableFuture<Ack> sendPayment(final URL url,final Protos.Payment payment){
  return executor.submit(new Callable<Ack>(){
    @Override public Ack call() throws Exception {
      HttpURLConnection connection=(HttpURLConnection)url.openConnection();
      connection.setRequestMethod("String_Node_Str");
      connection.setRequestProperty("String_Node_Str","String_Node_Str");
      connection.setRequestProperty("String_Node_Str","String_Node_Str");
      connection.setRequestProperty("String_Node_Str",Integer.toString(payment.getSerializedSize()));
      connection.setUseCaches(false);
      connection.setDoInput(true);
      connection.setDoOutput(true);
      DataOutputStream outStream=new DataOutputStream(connection.getOutputStream());
      payment.writeTo(outStream);
      outStream.flush();
      outStream.close();
      InputStream inStream=connection.getInputStream();
      Protos.PaymentACK.Builder paymentAckBuilder=Protos.PaymentACK.newBuilder().mergeFrom(inStream);
      Protos.PaymentACK paymentAck=paymentAckBuilder.build();
      String memo="String_Node_Str";
      if (paymentAck.hasMemo())       memo=paymentAck.getMemo();
      return new Ack(memo);
    }
  }
);
}

Fixed version (ground truth):
@VisibleForTesting protected ListenableFuture<Ack> sendPayment(final URL url,final Protos.Payment payment){
  return executor.submit(new Callable<Ack>(){
    @Override public Ack call() throws Exception {
      HttpURLConnection connection=(HttpURLConnection)url.openConnection();
      connection.setRequestMethod("String_Node_Str");
      connection.setRequestProperty("String_Node_Str","String_Node_Str");
      connection.setRequestProperty("String_Node_Str","String_Node_Str");
      connection.setRequestProperty("String_Node_Str",Integer.toString(payment.getSerializedSize()));
      connection.setUseCaches(false);
      connection.setDoInput(true);
      connection.setDoOutput(true);
      DataOutputStream outStream=new DataOutputStream(connection.getOutputStream());
      payment.writeTo(outStream);
      outStream.flush();
      outStream.close();
      InputStream inStream=connection.getInputStream();
      Protos.PaymentACK.Builder paymentAckBuilder=Protos.PaymentACK.newBuilder().mergeFrom(inStream);
      Protos.PaymentACK paymentAck=paymentAckBuilder.build();
      String memo=null;
      if (paymentAck.hasMemo())       memo=paymentAck.getMemo();
      return new Ack(memo);
    }
  }
);
}
Program: 85747
Project: 85747
Buggy source:
private String getNameFromCert(TrustAnchor rootAuthority) throws PaymentRequestException.PkiVerificationException {
  org.spongycastle.asn1.x500.X500Name name=new X500Name(rootAuthority.getTrustedCert().getSubjectX500Principal().getName());
  String commonName=null, org=null, location=null, country=null;
  for (  RDN rdn : name.getRDNs()) {
    AttributeTypeAndValue pair=rdn.getFirst();
    String val=((ASN1String)pair.getValue()).getString();
    if (pair.getType().equals(RFC4519Style.cn))     commonName=val;
 else     if (pair.getType().equals(RFC4519Style.o))     org=val;
 else     if (pair.getType().equals(RFC4519Style.l))     location=val;
 else     if (pair.getType().equals(RFC4519Style.c))     country=val;
  }
  if (org != null && location != null && country != null) {
    return org + "String_Node_Str" + location+ "String_Node_Str"+ country;
  }
 else {
    if (commonName == null)     throw new PaymentRequestException.PkiVerificationException("String_Node_Str");
    return commonName;
  }
}

Fixed version (ground truth):
private String getNameFromCert(TrustAnchor rootAuthority) throws PaymentRequestException.PkiVerificationException {
  org.spongycastle.asn1.x500.X500Name name=new X500Name(rootAuthority.getTrustedCert().getSubjectX500Principal().getName());
  String commonName=null, org=null, location=null, country=null;
  for (  RDN rdn : name.getRDNs()) {
    AttributeTypeAndValue pair=rdn.getFirst();
    String val=((ASN1String)pair.getValue()).getString();
    if (pair.getType().equals(RFC4519Style.cn))     commonName=val;
 else     if (pair.getType().equals(RFC4519Style.o))     org=val;
 else     if (pair.getType().equals(RFC4519Style.l))     location=val;
 else     if (pair.getType().equals(RFC4519Style.c))     country=val;
  }
  if (org != null) {
    return Joiner.on("String_Node_Str").skipNulls().join(org,location,country);
  }
 else {
    if (commonName == null)     throw new PaymentRequestException.PkiVerificationException("String_Node_Str");
    return commonName;
  }
}
Program: 85748
Project: 85748
Buggy source:
@Override public void onKeysAdded(Wallet wallet,List<ECKey> keys){
  Uninterruptibles.putUninterruptibly(jobQueue,recalculateRunnable);
}

Fixed version (ground truth):
@Override public void onKeysAdded(Wallet wallet,List<ECKey> keys){
  queueRecalc();
}
Program: 85749
Project: 85749
Buggy source:
@Override public void onScriptsAdded(Wallet wallet,List<Script> scripts){
  Uninterruptibles.putUninterruptibly(jobQueue,recalculateRunnable);
}

Fixed version (ground truth):
@Override public void onScriptsAdded(Wallet wallet,List<Script> scripts){
  queueRecalc();
}
Program: 85750
Project: 85750
Buggy source:
@Test public void watchingScriptsConfirmed() throws Exception {
  ECKey key=new ECKey();
  Address watchedAddress=key.toAddress(params);
  wallet.addWatchedAddress(watchedAddress);
  Transaction t1=createFakeTx(params,CENT,watchedAddress);
  StoredBlock b3=createFakeBlock(blockStore,t1).storedBlock;
  wallet.receiveFromBlock(t1,b3,BlockChain.NewBlockType.BEST_CHAIN,0);
  assertEquals(BigInteger.ZERO,wallet.getBalance());
  assertEquals(CENT,wallet.getWatchedBalance());
  Address notMyAddr=new ECKey().toAddress(params);
  assertNull(wallet.createSend(notMyAddr,CENT));
}

Fixed version (ground truth):
@Test(expected=InsufficientMoneyException.class) public void watchingScriptsConfirmed() throws Exception {
  ECKey key=new ECKey();
  Address watchedAddress=key.toAddress(params);
  wallet.addWatchedAddress(watchedAddress);
  Transaction t1=createFakeTx(params,CENT,watchedAddress);
  StoredBlock b3=createFakeBlock(blockStore,t1).storedBlock;
  wallet.receiveFromBlock(t1,b3,BlockChain.NewBlockType.BEST_CHAIN,0);
  assertEquals(BigInteger.ZERO,wallet.getBalance());
  assertEquals(CENT,wallet.getWatchedBalance());
  Address notMyAddr=new ECKey().toAddress(params);
  wallet.createSend(notMyAddr,CENT);
}
Program: 85751
Project: 85751
Buggy source:
@Test public void disconnectOldVersions1() throws Exception {
  final SettableFuture<Void> connectedFuture=SettableFuture.create();
  final SettableFuture<Void> disconnectedFuture=SettableFuture.create();
  peer.addEventListener(new AbstractPeerEventListener(){
    @Override public void onPeerConnected(    Peer peer,    int peerCount){
      connectedFuture.set(null);
    }
    @Override public void onPeerDisconnected(    Peer peer,    int peerCount){
      disconnectedFuture.set(null);
    }
  }
);
  connectWithVersion(500);
  connectedFuture.get();
  disconnectedFuture.get();
  try {
    peer.writeTarget.writeBytes(new byte[1]);
    fail();
  }
 catch (  IOException e) {
    assertTrue((e.getCause() != null && e.getCause() instanceof CancelledKeyException) || (e instanceof SocketException && e.getMessage().equals("String_Node_Str")));
  }
}

Fixed version (ground truth):
@Test public void disconnectOldVersions1() throws Exception {
  final SettableFuture<Void> connectedFuture=SettableFuture.create();
  final SettableFuture<Void> disconnectedFuture=SettableFuture.create();
  peer.addEventListener(new AbstractPeerEventListener(){
    @Override public void onPeerConnected(    Peer peer,    int peerCount){
      connectedFuture.set(null);
    }
    @Override public void onPeerDisconnected(    Peer peer,    int peerCount){
      disconnectedFuture.set(null);
    }
  }
);
  connectWithVersion(500);
  Uninterruptibles.getUninterruptibly(connectedFuture);
  Uninterruptibles.getUninterruptibly(disconnectedFuture);
  try {
    peer.writeTarget.writeBytes(new byte[1]);
    fail();
  }
 catch (  IOException e) {
    assertTrue((e.getCause() != null && e.getCause() instanceof CancelledKeyException) || (e instanceof SocketException && e.getMessage().equals("String_Node_Str")));
  }
}
Program: 85752
Project: 85752
Buggy source:
private void processVersionMessage(VersionMessage m) throws ProtocolException {
  if (vPeerVersionMessage != null)   throw new ProtocolException("String_Node_Str");
  vPeerVersionMessage=m;
  int peerVersion=vPeerVersionMessage.clientVersion;
  PeerAddress peerAddress=getAddress();
  log.info("String_Node_Str",new Object[]{peerAddress == null ? "String_Node_Str" : peerAddress.getAddr().getHostAddress(),peerVersion,vPeerVersionMessage.subVer,vPeerVersionMessage.localServices,new Date(vPeerVersionMessage.time * 1000),vPeerVersionMessage.bestHeight});
  sendMessage(new VersionAck());
  if (!vPeerVersionMessage.hasBlockChain() || (!params.allowEmptyPeerChain() && vPeerVersionMessage.bestHeight <= 0)) {
    throw new ProtocolException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void processVersionMessage(VersionMessage m) throws ProtocolException {
  if (vPeerVersionMessage != null)   throw new ProtocolException("String_Node_Str");
  vPeerVersionMessage=m;
  int peerVersion=vPeerVersionMessage.clientVersion;
  PeerAddress peerAddress=getAddress();
  long peerTime=vPeerVersionMessage.time * 1000;
  log.info("String_Node_Str",peerAddress == null ? "String_Node_Str" : peerAddress.getAddr().getHostAddress(),peerVersion,vPeerVersionMessage.subVer,vPeerVersionMessage.localServices,String.format("String_Node_Str",peerTime,peerTime),vPeerVersionMessage.bestHeight);
  sendMessage(new VersionAck());
  if (!vPeerVersionMessage.hasBlockChain() || (!params.allowEmptyPeerChain() && vPeerVersionMessage.bestHeight <= 0)) {
    throw new ProtocolException("String_Node_Str");
  }
}