nus-yam/ex-repair huggingface dataset:
Program: 85797
Project: 85797
Buggy source:
@GuardedBy("String_Node_Str") private void receiveInitiate(Protos.Initiate initiate,BigInteger minChannelSize) throws VerificationException, ValueOutOfRangeException {
  log.info("String_Node_Str");
  state=new PaymentChannelClientState(wallet,myKey,new ECKey(null,initiate.getMultisigKey().toByteArray()),minChannelSize,initiate.getExpireTimeSecs());
  state.initiate();
  step=InitStep.WAITING_FOR_REFUND_RETURN;
  Protos.ProvideRefund.Builder provideRefundBuilder=Protos.ProvideRefund.newBuilder().setMultisigKey(ByteString.copyFrom(myKey.getPubKey())).setTx(ByteString.copyFrom(state.getIncompleteRefundTransaction().bitcoinSerialize()));
  conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder().setProvideRefund(provideRefundBuilder).setType(Protos.TwoWayChannelMessage.MessageType.PROVIDE_REFUND).build());
}

Fixed version (ground truth):
@GuardedBy("String_Node_Str") private void receiveInitiate(Protos.Initiate initiate,BigInteger contractValue) throws VerificationException, ValueOutOfRangeException {
  log.info("String_Node_Str");
  state=new PaymentChannelClientState(wallet,myKey,new ECKey(null,initiate.getMultisigKey().toByteArray()),contractValue,initiate.getExpireTimeSecs());
  state.initiate();
  step=InitStep.WAITING_FOR_REFUND_RETURN;
  Protos.ProvideRefund.Builder provideRefundBuilder=Protos.ProvideRefund.newBuilder().setMultisigKey(ByteString.copyFrom(myKey.getPubKey())).setTx(ByteString.copyFrom(state.getIncompleteRefundTransaction().bitcoinSerialize()));
  conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder().setProvideRefund(provideRefundBuilder).setType(Protos.TwoWayChannelMessage.MessageType.PROVIDE_REFUND).build());
}
Program: 85798
Project: 85798
Buggy source:
/** 
 * Password based encryption using AES - CBC 256 bits.
 */
@Override public EncryptedPrivateKey encrypt(byte[] plainBytes,KeyParameter aesKey) throws KeyCrypterException {
  Preconditions.checkNotNull(plainBytes);
  Preconditions.checkNotNull(aesKey);
  try {
    byte[] iv=new byte[BLOCK_LENGTH];
    secureRandom.nextBytes(iv);
    ParametersWithIV keyWithIv=new ParametersWithIV(aesKey,iv);
    BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(true,keyWithIv);
    byte[] encryptedBytes=new byte[cipher.getOutputSize(plainBytes.length)];
    int length=cipher.processBytes(plainBytes,0,plainBytes.length,encryptedBytes,0);
    cipher.doFinal(encryptedBytes,length);
    return new EncryptedPrivateKey(iv,encryptedBytes);
  }
 catch (  Exception e) {
    throw new KeyCrypterException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Password based encryption using AES - CBC 256 bits.
 */
@Override public EncryptedPrivateKey encrypt(byte[] plainBytes,KeyParameter aesKey) throws KeyCrypterException {
  checkNotNull(plainBytes);
  checkNotNull(aesKey);
  try {
    byte[] iv=new byte[BLOCK_LENGTH];
    secureRandom.nextBytes(iv);
    ParametersWithIV keyWithIv=new ParametersWithIV(aesKey,iv);
    BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(true,keyWithIv);
    byte[] encryptedBytes=new byte[cipher.getOutputSize(plainBytes.length)];
    int length=cipher.processBytes(plainBytes,0,plainBytes.length,encryptedBytes,0);
    cipher.doFinal(encryptedBytes,length);
    return new EncryptedPrivateKey(iv,encryptedBytes);
  }
 catch (  Exception e) {
    throw new KeyCrypterException("String_Node_Str",e);
  }
}
Program: 85799
Project: 85799
Buggy source:
/** 
 * Convert a CharSequence (which are UTF16) into a byte array. Note: a String.getBytes() is not used to avoid creating a String of the password in the JVM.
 */
private byte[] convertToByteArray(CharSequence charSequence){
  Preconditions.checkNotNull(charSequence);
  byte[] byteArray=new byte[charSequence.length() << 1];
  for (int i=0; i < charSequence.length(); i++) {
    int bytePosition=i << 1;
    byteArray[bytePosition]=(byte)((charSequence.charAt(i) & 0xFF00) >> 8);
    byteArray[bytePosition + 1]=(byte)(charSequence.charAt(i) & 0x00FF);
  }
  return byteArray;
}

Fixed version (ground truth):
/** 
 * Convert a CharSequence (which are UTF16) into a byte array. Note: a String.getBytes() is not used to avoid creating a String of the password in the JVM.
 */
private static byte[] convertToByteArray(CharSequence charSequence){
  checkNotNull(charSequence);
  byte[] byteArray=new byte[charSequence.length() << 1];
  for (int i=0; i < charSequence.length(); i++) {
    int bytePosition=i << 1;
    byteArray[bytePosition]=(byte)((charSequence.charAt(i) & 0xFF00) >> 8);
    byteArray[bytePosition + 1]=(byte)(charSequence.charAt(i) & 0x00FF);
  }
  return byteArray;
}
Program: 85800
Project: 85800
Buggy source:
/** 
 * Encryption/ Decryption using specified Scrypt parameters.
 * @param scryptParameters ScryptParameters to use
 * @throws NullPointerException if the scryptParameters or any of its N, R or P is null.
 */
public KeyCrypterScrypt(ScryptParameters scryptParameters){
  this.scryptParameters=Preconditions.checkNotNull(scryptParameters);
  if (scryptParameters.getSalt() == null || scryptParameters.getSalt().toByteArray() == null || scryptParameters.getSalt().toByteArray().length == 0) {
    log.warn("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Encryption/ Decryption using specified Scrypt parameters.
 * @param scryptParameters ScryptParameters to use
 * @throws NullPointerException if the scryptParameters or any of its N, R or P is null.
 */
public KeyCrypterScrypt(ScryptParameters scryptParameters){
  this.scryptParameters=checkNotNull(scryptParameters);
  if (scryptParameters.getSalt() == null || scryptParameters.getSalt().toByteArray() == null || scryptParameters.getSalt().toByteArray().length == 0) {
    log.warn("String_Node_Str");
  }
}
Program: 85801
Project: 85801
Buggy source:
/** 
 * Decrypt bytes previously encrypted with this class.
 * @param privateKeyToDecode    The private key to decrypt
 * @param aesKey           The AES key to use for decryption
 * @return                 The decrypted bytes
 * @throws KeyCrypterException if bytes could not be decoded to a valid key
 */
@Override public byte[] decrypt(EncryptedPrivateKey privateKeyToDecode,KeyParameter aesKey) throws KeyCrypterException {
  Preconditions.checkNotNull(privateKeyToDecode);
  Preconditions.checkNotNull(aesKey);
  try {
    ParametersWithIV keyWithIv=new ParametersWithIV(new KeyParameter(aesKey.getKey()),privateKeyToDecode.getInitialisationVector());
    BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false,keyWithIv);
    byte[] cipherBytes=privateKeyToDecode.getEncryptedBytes();
    int minimumSize=cipher.getOutputSize(cipherBytes.length);
    byte[] outputBuffer=new byte[minimumSize];
    int length1=cipher.processBytes(cipherBytes,0,cipherBytes.length,outputBuffer,0);
    int length2=cipher.doFinal(outputBuffer,length1);
    int actualLength=length1 + length2;
    byte[] decryptedBytes=new byte[actualLength];
    System.arraycopy(outputBuffer,0,decryptedBytes,0,actualLength);
    return decryptedBytes;
  }
 catch (  Exception e) {
    throw new KeyCrypterException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Decrypt bytes previously encrypted with this class.
 * @param privateKeyToDecode    The private key to decrypt
 * @param aesKey           The AES key to use for decryption
 * @return                 The decrypted bytes
 * @throws KeyCrypterException if bytes could not be decoded to a valid key
 */
@Override public byte[] decrypt(EncryptedPrivateKey privateKeyToDecode,KeyParameter aesKey) throws KeyCrypterException {
  checkNotNull(privateKeyToDecode);
  checkNotNull(aesKey);
  try {
    ParametersWithIV keyWithIv=new ParametersWithIV(new KeyParameter(aesKey.getKey()),privateKeyToDecode.getInitialisationVector());
    BufferedBlockCipher cipher=new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
    cipher.init(false,keyWithIv);
    byte[] cipherBytes=privateKeyToDecode.getEncryptedBytes();
    int minimumSize=cipher.getOutputSize(cipherBytes.length);
    byte[] outputBuffer=new byte[minimumSize];
    int length1=cipher.processBytes(cipherBytes,0,cipherBytes.length,outputBuffer,0);
    int length2=cipher.doFinal(outputBuffer,length1);
    int actualLength=length1 + length2;
    byte[] decryptedBytes=new byte[actualLength];
    System.arraycopy(outputBuffer,0,decryptedBytes,0,actualLength);
    return decryptedBytes;
  }
 catch (  Exception e) {
    throw new KeyCrypterException("String_Node_Str",e);
  }
}
Program: 85802
Project: 85802
Buggy source:
/** 
 * Contruct a block object from the Bitcoin wire format.
 * @param params NetworkParameters object.
 * @param parseLazy Whether to perform a full parse immediately or delay until a read is requested.
 * @param parseRetain Whether to retain the backing byte array for quick reserialization.  If true and the backing byte array is invalidated due to modification of a field then  the cached bytes may be repopulated and retained if the message is serialized again in the future.
 * @param length The length of message if known.  Usually this is provided when deserializing of the wireas the length will be provided as part of the header.  If unknown then set to Message.UNKNOWN_LENGTH
 * @throws ProtocolException
 */
public Block(NetworkParameters params,byte[] payloadBytes,boolean parseLazy,boolean parseRetain,int length) throws ProtocolException {
  super(params,payloadBytes,0,parseLazy,parseRetain,length);
}

Fixed version (ground truth):
/** 
 * Construct a block initialized with all the given fields.
 * @param params Which network the block is for.
 * @param version This should usually be set to 1 or 2, depending on if the height is in the coinbase input.
 * @param prevBlockHash Reference to previous block in the chain or {@link Sha256Hash#ZERO_HASH} if genesis.
 * @param merkleRoot The root of the merkle tree formed by the transactions.
 * @param time UNIX time when the block was mined.
 * @param difficultyTarget Number which this block hashes lower than.
 * @param nonce Arbitrary number to make the block hash lower than the target.
 * @param transactions List of transactions including the coinbase.
 */
public Block(NetworkParameters params,long version,Sha256Hash prevBlockHash,Sha256Hash merkleRoot,long time,long difficultyTarget,long nonce,List<Transaction> transactions){
  super(params);
  this.version=version;
  this.prevBlockHash=prevBlockHash;
  this.merkleRoot=merkleRoot;
  this.time=time;
  this.difficultyTarget=difficultyTarget;
  this.nonce=nonce;
  this.transactions=new LinkedList<Transaction>();
  this.transactions.addAll(transactions);
}
Program: 85803
Project: 85803
Buggy source:
/** 
 * Called when download is initiated.
 * @param blocks the number of blocks to download, estimated
 */
protected void startDownload(int blocks){
  if (blocks > 0)   System.out.println("String_Node_Str" + blocks + "String_Node_Str"+ (blocks > 1000 ? "String_Node_Str" : "String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Called when download is initiated.
 * @param blocks the number of blocks to download, estimated
 */
protected void startDownload(int blocks){
  if (blocks > 0)   log.info("String_Node_Str" + blocks + "String_Node_Str"+ (blocks > 1000 ? "String_Node_Str" : "String_Node_Str"));
}
Program: 85804
Project: 85804
Buggy source:
/** 
 * Called when download progress is made.
 * @param pct  the percentage of chain downloaded, estimated
 * @param date the date of the last block downloaded
 */
protected void progress(double pct,int blocksSoFar,Date date){
  System.out.println(String.format("String_Node_Str",(int)pct,blocksSoFar,DateFormat.getDateTimeInstance().format(date)));
}

Fixed version (ground truth):
/** 
 * Called when download progress is made.
 * @param pct  the percentage of chain downloaded, estimated
 * @param date the date of the last block downloaded
 */
protected void progress(double pct,int blocksSoFar,Date date){
  log.info(String.format("String_Node_Str",(int)pct,blocksSoFar,DateFormat.getDateTimeInstance().format(date)));
}
Program: 85805
Project: 85805
Buggy source:
@Test public void testLazyParsing() throws Exception {
  BitcoinSerializer bs=new BitcoinSerializer(MainNetParams.get(),true,false);
  ByteArrayInputStream bais=new ByteArrayInputStream(txMessage);
  Transaction tx=(Transaction)bs.deserialize(bais);
  assertNotNull(tx);
  assertEquals(false,tx.isParsed());
  assertEquals(true,tx.isCached());
  tx.getInputs();
  assertEquals(true,tx.isParsed());
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  bs.serialize(tx,bos);
  System.out.println(Utils.bytesToHexString(txMessage));
  System.out.println(Utils.bytesToHexString(bos.toByteArray()));
  assertEquals(true,Arrays.equals(txMessage,bos.toByteArray()));
}

Fixed version (ground truth):
@Test public void testLazyParsing() throws Exception {
  BitcoinSerializer bs=new BitcoinSerializer(MainNetParams.get(),true,false);
  ByteArrayInputStream bais=new ByteArrayInputStream(txMessage);
  Transaction tx=(Transaction)bs.deserialize(bais);
  assertNotNull(tx);
  assertEquals(false,tx.isParsed());
  assertEquals(true,tx.isCached());
  tx.getInputs();
  assertEquals(true,tx.isParsed());
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  bs.serialize(tx,bos);
  assertEquals(true,Arrays.equals(txMessage,bos.toByteArray()));
}
Program: 85807
Project: 85807
Buggy source:
private static void executeCheckSig(Transaction txContainingThis,int index,Script script,LinkedList<byte[]> stack,int lastCodeSepLocation,int opcode) throws ScriptException {
  if (stack.size() < 2)   throw new ScriptException("String_Node_Str");
  byte[] pubKey=stack.pollLast();
  byte[] sig=stack.pollLast();
  byte[] prog=script.getProgram();
  byte[] connectedScript=Arrays.copyOfRange(prog,lastCodeSepLocation,prog.length);
  UnsafeByteArrayOutputStream outStream=new UnsafeByteArrayOutputStream(sig.length + 1);
  try {
    writeBytes(outStream,sig);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  connectedScript=removeAllInstancesOf(connectedScript,outStream.toByteArray());
  Sha256Hash hash=txContainingThis.hashTransactionForSignature(index,connectedScript,sig[sig.length - 1]);
  boolean sigValid;
  try {
    sigValid=ECKey.verify(hash.getBytes(),Arrays.copyOf(sig,sig.length - 1),pubKey);
  }
 catch (  Exception e1) {
    log.warn(e1.toString());
    sigValid=false;
  }
  if (opcode == OP_CHECKSIG)   stack.add(sigValid ? new byte[]{1} : new byte[]{0});
 else   if (opcode == OP_CHECKSIGVERIFY)   if (!sigValid)   throw new ScriptException("String_Node_Str");
}

Fixed version (ground truth):
private static void executeCheckSig(Transaction txContainingThis,int index,Script script,LinkedList<byte[]> stack,int lastCodeSepLocation,int opcode) throws ScriptException {
  if (stack.size() < 2)   throw new ScriptException("String_Node_Str");
  byte[] pubKey=stack.pollLast();
  byte[] sig=stack.pollLast();
  if (sig.length == 0 || pubKey.length == 0)   throw new ScriptException("String_Node_Str");
  byte[] prog=script.getProgram();
  byte[] connectedScript=Arrays.copyOfRange(prog,lastCodeSepLocation,prog.length);
  UnsafeByteArrayOutputStream outStream=new UnsafeByteArrayOutputStream(sig.length + 1);
  try {
    writeBytes(outStream,sig);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
  connectedScript=removeAllInstancesOf(connectedScript,outStream.toByteArray());
  Sha256Hash hash=txContainingThis.hashTransactionForSignature(index,connectedScript,sig[sig.length - 1]);
  boolean sigValid;
  try {
    sigValid=ECKey.verify(hash.getBytes(),Arrays.copyOf(sig,sig.length - 1),pubKey);
  }
 catch (  Exception e1) {
    log.warn(e1.toString());
    sigValid=false;
  }
  if (opcode == OP_CHECKSIG)   stack.add(sigValid ? new byte[]{1} : new byte[]{0});
 else   if (opcode == OP_CHECKSIGVERIFY)   if (!sigValid)   throw new ScriptException("String_Node_Str");
}
Program: 85815
Project: 85815
Buggy source:
/** 
 * Work around lack of unsigned types in Java.
 */
public static boolean isLessThanUnsigned(long n1,long n2){
  return (n1 < n2) ^ ((n1 < 0) != (n2 < 0));
}

Fixed version (ground truth):
/** 
 * Work around lack of unsigned types in Java.
 */
public static boolean isLessThanUnsigned(long n1,long n2){
  return UnsignedLongs.compare(n1,n2) < 0;
}
Program: 85816
Project: 85816
Buggy source:
/** 
 * Gets the minimum encoded size of the given value.
 */
public static int sizeOf(long value){
  if (isLessThanUnsigned(value,253))   return 1;
 else   if (isLessThanUnsigned(value,65536))   return 3;
 else   if (isLessThanUnsigned(value,4294967296L))   return 5;
 else   return 9;
}

Fixed version (ground truth):
/** 
 * Gets the minimum encoded size of the given value.
 */
public static int sizeOf(long value){
  if (isLessThanUnsigned(value,253))   return 1;
 else   if (isLessThanUnsigned(value,65536))   return 3;
 else   if (isLessThanUnsigned(value,UnsignedInteger.MAX_VALUE.longValue()))   return 5;
 else   return 9;
}
Program: 85817
Project: 85817
Buggy source:
public byte[] encodeBE(){
  if (isLessThanUnsigned(value,253)) {
    return new byte[]{(byte)value};
  }
 else   if (isLessThanUnsigned(value,65536)) {
    return new byte[]{(byte)253,(byte)(value),(byte)(value >> 8)};
  }
 else   if (isLessThanUnsigned(value,4294967295L)) {
    byte[] bytes=new byte[5];
    bytes[0]=(byte)254;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    return bytes;
  }
 else {
    byte[] bytes=new byte[9];
    bytes[0]=(byte)255;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    Utils.uint32ToByteArrayLE(value >>> 32,bytes,5);
    return bytes;
  }
}

Fixed version (ground truth):
public byte[] encodeBE(){
  if (isLessThanUnsigned(value,253)) {
    return new byte[]{(byte)value};
  }
 else   if (isLessThanUnsigned(value,65536)) {
    return new byte[]{(byte)253,(byte)(value),(byte)(value >> 8)};
  }
 else   if (isLessThanUnsigned(value,UnsignedInteger.MAX_VALUE.longValue())) {
    byte[] bytes=new byte[5];
    bytes[0]=(byte)254;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    return bytes;
  }
 else {
    byte[] bytes=new byte[9];
    bytes[0]=(byte)255;
    Utils.uint32ToByteArrayLE(value,bytes,1);
    Utils.uint32ToByteArrayLE(value >>> 32,bytes,5);
    return bytes;
  }
}
Program: 85818
Project: 85818
Buggy source:
/** 
 * Handle when a transaction becomes newly active on the best chain, either due to receiving a new block or a re-org making inactive transactions active.
 */
private void processTxFromBestChain(Transaction tx) throws VerificationException {
  checkState(lock.isLocked());
  boolean isDeadCoinbase=tx.isCoinBase() && dead.containsKey(tx.getHash());
  if (isDeadCoinbase) {
    log.info("String_Node_Str",tx.getHashAsString(),tx.getConfidence().getConfidenceType().name());
    dead.remove(tx.getHash());
  }
  if (inactive.containsKey(tx.getHash())) {
    log.info("String_Node_Str",tx.getHashAsString());
    inactive.remove(tx.getHash());
  }
  updateForSpends(tx,true);
  boolean hasOutputsToMe=tx.getValueSentToMe(this,true).compareTo(BigInteger.ZERO) > 0;
  if (hasOutputsToMe) {
    if (tx.isEveryOwnedOutputSpent(this)) {
      log.info("String_Node_Str",tx.getHashAsString());
      addWalletTransaction(Pool.SPENT,tx);
    }
 else {
      log.info("String_Node_Str",tx.getHashAsString());
      addWalletTransaction(Pool.UNSPENT,tx);
    }
  }
 else   if (tx.getValueSentFromMe(this).compareTo(BigInteger.ZERO) > 0) {
    log.info("String_Node_Str",tx.getHashAsString());
    addWalletTransaction(Pool.SPENT,tx);
  }
  TransactionInput doubleSpent=findDoubleSpendAgainstPending(tx);
  if (doubleSpent != null) {
    killTx(tx,doubleSpent,doubleSpent.getParentTransaction());
  }
}

Fixed version (ground truth):
/** 
 * Handle when a transaction becomes newly active on the best chain, either due to receiving a new block or a re-org making inactive transactions active.
 */
private void processTxFromBestChain(Transaction tx) throws VerificationException {
  checkState(lock.isLocked());
  boolean isDeadCoinbase=tx.isCoinBase() && dead.containsKey(tx.getHash());
  if (isDeadCoinbase) {
    log.info("String_Node_Str",tx.getHashAsString(),tx.getConfidence().getConfidenceType().name());
    dead.remove(tx.getHash());
  }
  if (inactive.containsKey(tx.getHash())) {
    log.info("String_Node_Str",tx.getHashAsString());
    inactive.remove(tx.getHash());
  }
  updateForSpends(tx,true);
  boolean hasOutputsToMe=tx.getValueSentToMe(this,true).compareTo(BigInteger.ZERO) > 0;
  if (hasOutputsToMe) {
    if (tx.isEveryOwnedOutputSpent(this)) {
      log.info("String_Node_Str",tx.getHashAsString());
      addWalletTransaction(Pool.SPENT,tx);
    }
 else {
      log.info("String_Node_Str",tx.getHashAsString());
      addWalletTransaction(Pool.UNSPENT,tx);
    }
  }
 else   if (tx.getValueSentFromMe(this).compareTo(BigInteger.ZERO) > 0) {
    log.info("String_Node_Str",tx.getHashAsString());
    addWalletTransaction(Pool.SPENT,tx);
  }
  checkForDoubleSpendAgainstPending(tx,true);
}
Program: 85819
Project: 85819
Buggy source:
private void killTx(Transaction overridingTx,TransactionInput overridingInput,Transaction killedTx){
  TransactionOutPoint overriddenOutPoint=overridingInput.getOutpoint();
  log.warn("String_Node_Str",overriddenOutPoint,killedTx.getHashAsString());
  log.warn("String_Node_Str",overridingTx.getHashAsString());
  checkState(overridingInput.connect(overridingTx,TransactionInput.ConnectMode.DISCONNECT_ON_CONFLICT) == TransactionInput.ConnectionResult.SUCCESS);
  pending.remove(killedTx.getHash());
  addWalletTransaction(Pool.DEAD,killedTx);
  for (  TransactionInput deadInput : killedTx.getInputs())   deadInput.disconnect();
  killedTx.getConfidence().setOverridingTransaction(overridingTx);
}

Fixed version (ground truth):
private void killTx(Transaction overridingTx,TransactionInput overridingInput,Transaction killedTx){
  TransactionOutPoint overriddenOutPoint=overridingInput.getOutpoint();
  log.warn("String_Node_Str",overriddenOutPoint,killedTx.getHashAsString());
  log.warn("String_Node_Str",overridingTx.getHashAsString());
  pending.remove(killedTx.getHash());
  addWalletTransaction(Pool.DEAD,killedTx);
  log.info("String_Node_Str");
  for (  TransactionInput deadInput : killedTx.getInputs()) {
    Transaction connected=deadInput.getOutpoint().fromTx;
    if (connected == null)     continue;
    deadInput.disconnect();
    maybeMovePool(connected,"String_Node_Str");
  }
  log.info("String_Node_Str");
  TransactionInput.ConnectionResult result=overridingInput.connect(unspent,TransactionInput.ConnectMode.DISCONNECT_ON_CONFLICT);
  if (result == TransactionInput.ConnectionResult.SUCCESS) {
    maybeMovePool(overridingInput.getOutpoint().fromTx,"String_Node_Str");
  }
 else {
    result=overridingInput.connect(spent,TransactionInput.ConnectMode.DISCONNECT_ON_CONFLICT);
    if (result == TransactionInput.ConnectionResult.SUCCESS) {
      maybeMovePool(overridingInput.getOutpoint().fromTx,"String_Node_Str");
    }
  }
  log.info("String_Node_Str");
  killedTx.getConfidence().setOverridingTransaction(overridingTx);
}
Program: 85821
Project: 85821
Buggy source:
/** 
 * <p>Returns true if the given transaction sends coins to any of our keys, or has inputs spending any of our outputs, and if includeDoubleSpending is true, also returns true if tx has inputs that are spending outputs which are not ours but which are spent by pending transactions.</p> <p>Note that if the tx has inputs containing one of our keys, but the connected transaction is not in the wallet, it will not be considered relevant.</p>
 */
public boolean isTransactionRelevant(Transaction tx) throws ScriptException {
  lock.lock();
  try {
    return tx.getValueSentFromMe(this).compareTo(BigInteger.ZERO) > 0 || tx.getValueSentToMe(this).compareTo(BigInteger.ZERO) > 0 || findDoubleSpendAgainstPending(tx) != null;
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * <p>Returns true if the given transaction sends coins to any of our keys, or has inputs spending any of our outputs, and if includeDoubleSpending is true, also returns true if tx has inputs that are spending outputs which are not ours but which are spent by pending transactions.</p> <p>Note that if the tx has inputs containing one of our keys, but the connected transaction is not in the wallet, it will not be considered relevant.</p>
 */
public boolean isTransactionRelevant(Transaction tx) throws ScriptException {
  lock.lock();
  try {
    return tx.getValueSentFromMe(this).compareTo(BigInteger.ZERO) > 0 || tx.getValueSentToMe(this).compareTo(BigInteger.ZERO) > 0 || checkForDoubleSpendAgainstPending(tx,false);
  }
  finally {
    lock.unlock();
  }
}
Program: 85822
Project: 85822
Buggy source:
public boolean isConsistent(){
  lock.lock();
  try {
    boolean success=true;
    HashSet<Transaction> pendingInactive=new HashSet<Transaction>();
    pendingInactive.addAll(pending.values());
    pendingInactive.addAll(inactive.values());
    Set<Transaction> transactions=getTransactions(true,true);
    Set<Sha256Hash> hashes=new HashSet<Sha256Hash>();
    for (    Transaction tx : transactions) {
      hashes.add(tx.getHash());
    }
    int size1=transactions.size();
    if (size1 != hashes.size()) {
      log.error("String_Node_Str");
      success=false;
    }
    int size2=unspent.size() + spent.size() + pendingInactive.size()+ dead.size();
    if (size1 != size2) {
      log.error("String_Node_Str",size1,size2);
      success=false;
    }
    for (    Transaction tx : unspent.values()) {
      if (!tx.isConsistent(this,false)) {
        success=false;
        log.error("String_Node_Str",tx.getHashAsString());
      }
    }
    for (    Transaction tx : spent.values()) {
      if (!tx.isConsistent(this,true)) {
        success=false;
        log.error("String_Node_Str",tx.getHashAsString());
      }
    }
    return success;
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public boolean isConsistent(){
  lock.lock();
  try {
    boolean success=true;
    HashSet<Transaction> pendingInactive=new HashSet<Transaction>();
    pendingInactive.addAll(pending.values());
    pendingInactive.addAll(inactive.values());
    Set<Transaction> transactions=getTransactions(true,true);
    Set<Sha256Hash> hashes=new HashSet<Sha256Hash>();
    for (    Transaction tx : transactions) {
      hashes.add(tx.getHash());
    }
    int size1=transactions.size();
    if (size1 != hashes.size()) {
      log.error("String_Node_Str");
      success=false;
    }
    int size2=unspent.size() + spent.size() + pendingInactive.size()+ dead.size();
    if (size1 != size2) {
      log.error("String_Node_Str",size1,size2);
      success=false;
    }
    for (    Transaction tx : unspent.values()) {
      if (!tx.isConsistent(this,false)) {
        success=false;
        log.error("String_Node_Str",tx.getHashAsString());
      }
    }
    for (    Transaction tx : spent.values()) {
      if (!tx.isConsistent(this,true)) {
        success=false;
        log.error("String_Node_Str",tx.getHashAsString());
      }
    }
    if (!success)     log.error(toString());
    return success;
  }
  finally {
    lock.unlock();
  }
}
Program: 85827
Project: 85827
Buggy source:
private void processPong(Pong m){
  log.info("String_Node_Str",this,m.getNonce());
  for (  PendingPing ping : pendingPings) {
    if (m.getNonce() == ping.nonce) {
      pendingPings.remove(ping);
      ping.complete();
      return;
    }
  }
}

Fixed version (ground truth):
private void processPong(Pong m){
  for (  PendingPing ping : pendingPings) {
    if (m.getNonce() == ping.nonce) {
      pendingPings.remove(ping);
      ping.complete();
      return;
    }
  }
}
Program: 85828
Project: 85828
Buggy source:
public void run(){
  for (  GetDataRequest req : getDataFutures) {
    if (req.nonce == nonce) {
      req.future.cancel(true);
      getDataFutures.remove(req);
      break;
    }
  }
}

Fixed version (ground truth):
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);
    }
  }
}
Program: 85830
Project: 85830
Buggy source:
private void processNotFoundMessage(NotFoundMessage m){
  for (  GetDataRequest req : getDataFutures) {
    for (    InventoryItem item : m.getItems()) {
      if (item.hash.equals(req.hash)) {
        req.future.cancel(true);
        getDataFutures.remove(req);
        break;
      }
    }
  }
}

Fixed version (ground truth):
private void processNotFoundMessage(NotFoundMessage m){
  for (  GetDataRequest req : getDataFutures) {
    for (    InventoryItem item : m.getItems()) {
      if (item.hash.equals(req.hash)) {
        log.info("String_Node_Str",this,req.hash);
        req.future.cancel(true);
        getDataFutures.remove(req);
        break;
      }
    }
  }
}
Program: 85831
Project: 85831
Buggy source:
@Override public String toString(){
  PeerAddress addr=vAddress;
  if (addr == null) {
    return "String_Node_Str";
  }
 else {
    return "String_Node_Str" + addr.getAddr() + "String_Node_Str"+ addr.getPort()+ "String_Node_Str";
  }
}

Fixed version (ground truth):
@Override public String toString(){
  PeerAddress addr=vAddress;
  if (addr == null) {
    return "String_Node_Str";
  }
 else {
    return addr.toString();
  }
}
Program: 85833
Project: 85833
Buggy source:
@Test public void timeLockedTransaction() throws Exception {
  control.replay();
  connect();
  ECKey key=new ECKey();
  Wallet wallet=new Wallet(unitTestParams);
  wallet.addKey(key);
  peer.addWallet(wallet);
  final Transaction[] vtx=new Transaction[1];
  wallet.addEventListener(new AbstractWalletEventListener(){
    @Override public void onCoinsReceived(    Wallet wallet,    Transaction tx,    BigInteger prevBalance,    BigInteger newBalance){
      vtx[0]=tx;
    }
  }
);
  Transaction t1=TestUtils.createFakeTx(unitTestParams,Utils.toNanoCoins(1,0),key);
  inbound(peer,t1);
  GetDataMessage getdata=(GetDataMessage)outbound();
  inbound(peer,new NotFoundMessage(unitTestParams,getdata.getItems()));
  assertNotNull(vtx[0]);
  vtx[0]=null;
  Transaction t2=TestUtils.createFakeTx(unitTestParams,Utils.toNanoCoins(2,0),key);
  t2.setLockTime(999999);
  inbound(peer,t2);
  assertNull(vtx[0]);
  wallet.setAcceptTimeLockedTransactions(true);
  inbound(peer,t2);
  getdata=(GetDataMessage)outbound();
  inbound(peer,new NotFoundMessage(unitTestParams,getdata.getItems()));
  assertEquals(t2,vtx[0]);
}

Fixed version (ground truth):
public void timeLockedTransaction(boolean useNotFound) throws Exception {
  control.replay();
  connectWithVersion(useNotFound ? 70001 : 60001);
  ECKey key=new ECKey();
  Wallet wallet=new Wallet(unitTestParams);
  wallet.addKey(key);
  peer.addWallet(wallet);
  final Transaction[] vtx=new Transaction[1];
  wallet.addEventListener(new AbstractWalletEventListener(){
    @Override public void onCoinsReceived(    Wallet wallet,    Transaction tx,    BigInteger prevBalance,    BigInteger newBalance){
      vtx[0]=tx;
    }
  }
);
  Transaction t1=TestUtils.createFakeTx(unitTestParams,Utils.toNanoCoins(1,0),key);
  inbound(peer,t1);
  GetDataMessage getdata=(GetDataMessage)outbound();
  if (useNotFound) {
    inbound(peer,new NotFoundMessage(unitTestParams,getdata.getItems()));
  }
 else {
    bouncePing();
  }
  assertNotNull(vtx[0]);
  vtx[0]=null;
  Transaction t2=TestUtils.createFakeTx(unitTestParams,Utils.toNanoCoins(2,0),key);
  t2.setLockTime(999999);
  inbound(peer,t2);
  assertNull(vtx[0]);
  wallet.setAcceptTimeLockedTransactions(true);
  inbound(peer,t2);
  getdata=(GetDataMessage)outbound();
  if (useNotFound) {
    inbound(peer,new NotFoundMessage(unitTestParams,getdata.getItems()));
  }
 else {
    bouncePing();
  }
  assertEquals(t2,vtx[0]);
}
Program: 85834
Project: 85834
Buggy source:
private void connect(PeerHandler handler,Channel channel,ChannelHandlerContext ctx) throws Exception {
  handler.connectRequested(ctx,new UpstreamChannelStateEvent(channel,ChannelState.CONNECTED,socketAddress));
  VersionMessage peerVersion=new VersionMessage(unitTestParams,OTHER_PEER_CHAIN_HEIGHT);
  peerVersion.clientVersion=70001;
  DownstreamMessageEvent versionEvent=new DownstreamMessageEvent(channel,Channels.future(channel),peerVersion,null);
  handler.messageReceived(ctx,versionEvent);
}

Fixed version (ground truth):
private void connect(PeerHandler handler,Channel channel,ChannelHandlerContext ctx,int version) throws Exception {
  handler.connectRequested(ctx,new UpstreamChannelStateEvent(channel,ChannelState.CONNECTED,socketAddress));
  VersionMessage peerVersion=new VersionMessage(unitTestParams,OTHER_PEER_CHAIN_HEIGHT);
  peerVersion.clientVersion=version;
  DownstreamMessageEvent versionEvent=new DownstreamMessageEvent(channel,Channels.future(channel),peerVersion,null);
  handler.messageReceived(ctx,versionEvent);
}
Program: 85835
Project: 85835
Buggy source:
@Test public void invDownloadTxMultiPeer() throws Exception {
  ChannelHandlerContext ctx2=createChannelHandlerContext();
  Channel channel2=createChannel();
  createPipeline(channel2);
  control.replay();
  MockNetworkConnection conn2=createMockNetworkConnection();
  VersionMessage ver=new VersionMessage(unitTestParams,100);
  Peer peer2=new Peer(unitTestParams,blockChain,ver,memoryPool);
  peer2.addWallet(wallet);
  connect();
  connect(peer2.getHandler(),channel2,ctx2);
  BigInteger value=Utils.toNanoCoins(1,0);
  Transaction tx=createFakeTx(unitTestParams,value,address);
  InventoryMessage inv=new InventoryMessage(unitTestParams);
  InventoryItem item=new InventoryItem(InventoryItem.Type.Transaction,tx.getHash());
  inv.addItem(item);
  inbound(peer,inv);
  GetDataMessage message=(GetDataMessage)outbound();
  assertEquals(1,message.getItems().size());
  assertEquals(tx.getHash(),message.getItems().get(0).hash);
  assertTrue(memoryPool.maybeWasSeen(tx.getHash()));
  conn2.inbound(inv);
  assertFalse(event.hasCaptured());
}

Fixed version (ground truth):
@Test public void invDownloadTxMultiPeer() throws Exception {
  ChannelHandlerContext ctx2=createChannelHandlerContext();
  Channel channel2=createChannel();
  createPipeline(channel2);
  control.replay();
  MockNetworkConnection conn2=createMockNetworkConnection();
  VersionMessage ver=new VersionMessage(unitTestParams,100);
  Peer peer2=new Peer(unitTestParams,blockChain,ver,memoryPool);
  peer2.addWallet(wallet);
  connect();
  connect(peer2.getHandler(),channel2,ctx2,70001);
  BigInteger value=Utils.toNanoCoins(1,0);
  Transaction tx=createFakeTx(unitTestParams,value,address);
  InventoryMessage inv=new InventoryMessage(unitTestParams);
  InventoryItem item=new InventoryItem(InventoryItem.Type.Transaction,tx.getHash());
  inv.addItem(item);
  inbound(peer,inv);
  GetDataMessage message=(GetDataMessage)outbound();
  assertEquals(1,message.getItems().size());
  assertEquals(tx.getHash(),message.getItems().get(0).hash);
  assertTrue(memoryPool.maybeWasSeen(tx.getHash()));
  conn2.inbound(inv);
  assertFalse(event.hasCaptured());
}
Program: 85837
Project: 85837
Buggy source:
private void processPong(Pong m){
  PendingPing ping=null;
  for (  PendingPing pendingPing : pendingPings) {
    ping=pendingPing;
    if (m.getNonce() == ping.nonce) {
      pendingPings.remove(ping);
      break;
    }
  }
  if (ping != null)   ping.complete();
}

Fixed version (ground truth):
private void processPong(Pong m){
  log.info("String_Node_Str",this,m.getNonce());
  for (  PendingPing ping : pendingPings) {
    if (m.getNonce() == ping.nonce) {
      pendingPings.remove(ping);
      ping.complete();
      return;
    }
  }
}
Program: 85838
Project: 85838
Buggy source:
public void complete(){
  Preconditions.checkNotNull(future,"String_Node_Str");
  Long elapsed=Utils.now().getTime() - startTimeMsec;
  Peer.this.addPingTimeData(elapsed);
  log.debug("String_Node_Str",Peer.this.toString(),elapsed);
  future.set(elapsed);
  future=null;
}

Fixed version (ground truth):
public void complete(){
  checkNotNull(future,"String_Node_Str");
  Long elapsed=Utils.now().getTime() - startTimeMsec;
  Peer.this.addPingTimeData(elapsed);
  log.debug("String_Node_Str",Peer.this.toString(),elapsed);
  future.set(elapsed);
  future=null;
}
Program: 85839
Project: 85839
Buggy source:
@Test public void pingPong() throws Exception {
  control.replay();
  connect();
  Utils.rollMockClock(0);
  assertEquals(Long.MAX_VALUE,peer.getLastPingTime());
  assertEquals(Long.MAX_VALUE,peer.getPingTime());
  ListenableFuture<Long> future=peer.ping();
  Ping pingMsg=(Ping)outbound();
  assertEquals(Long.MAX_VALUE,peer.getLastPingTime());
  assertEquals(Long.MAX_VALUE,peer.getPingTime());
  assertFalse(future.isDone());
  Utils.rollMockClock(5);
  inbound(peer,new Pong(pingMsg.getNonce()));
  assertTrue(future.isDone());
  long elapsed=future.get();
  assertTrue("String_Node_Str" + elapsed,elapsed > 1000);
  assertEquals(elapsed,peer.getLastPingTime());
  assertEquals(elapsed,peer.getPingTime());
  future=peer.ping();
  outbound();
  Utils.rollMockClock(50);
  inbound(peer,new Pong(pingMsg.getNonce()));
  elapsed=future.get();
  assertEquals(elapsed,peer.getLastPingTime());
  assertEquals(7250,peer.getPingTime());
}

Fixed version (ground truth):
@Test public void pingPong() throws Exception {
  control.replay();
  connect();
  Utils.rollMockClock(0);
  assertEquals(Long.MAX_VALUE,peer.getLastPingTime());
  assertEquals(Long.MAX_VALUE,peer.getPingTime());
  ListenableFuture<Long> future=peer.ping();
  Ping pingMsg=(Ping)outbound();
  assertEquals(Long.MAX_VALUE,peer.getLastPingTime());
  assertEquals(Long.MAX_VALUE,peer.getPingTime());
  assertFalse(future.isDone());
  Utils.rollMockClock(5);
  inbound(peer,new Pong(pingMsg.getNonce()));
  assertTrue(future.isDone());
  long elapsed=future.get();
  assertTrue("String_Node_Str" + elapsed,elapsed > 1000);
  assertEquals(elapsed,peer.getLastPingTime());
  assertEquals(elapsed,peer.getPingTime());
  future=peer.ping();
  pingMsg=(Ping)outbound();
  Utils.rollMockClock(50);
  inbound(peer,new Pong(pingMsg.getNonce()));
  elapsed=future.get();
  assertEquals(elapsed,peer.getLastPingTime());
  assertEquals(7250,peer.getPingTime());
}
Program: 85840
Project: 85840
Buggy source:
private void setupPingingForNewPeer(final Peer peer){
  if (peer.getPeerVersionMessage().clientVersion < Pong.MIN_PROTOCOL_VERSION)   return;
  if (getPingIntervalMsec() <= 0)   return;
  new Runnable(){
    private boolean firstRun=true;
    public void run(){
      if (firstRun) {
        firstRun=false;
        try {
          peer.ping().addListener(this,MoreExecutors.sameThreadExecutor());
        }
 catch (        Exception e) {
          log.warn("String_Node_Str",peer,e.toString());
          return;
        }
        return;
      }
      final long interval=getPingIntervalMsec();
      if (interval <= 0)       return;
      pingTimer.schedule(new TimerTask(){
        @Override public void run(){
          try {
            if (!peers.contains(peer) || !PeerGroup.this.isRunning())             return;
            peer.ping().addListener(this,MoreExecutors.sameThreadExecutor());
          }
 catch (          Exception e) {
            log.warn("String_Node_Str",peer,e.toString());
          }
        }
      }
,interval);
    }
  }
.run();
}

Fixed version (ground truth):
private void setupPingingForNewPeer(final Peer peer){
  if (peer.getPeerVersionMessage().clientVersion < Pong.MIN_PROTOCOL_VERSION)   return;
  if (getPingIntervalMsec() <= 0)   return;
  final Runnable[] pingRunnable=new Runnable[1];
  pingRunnable[0]=new Runnable(){
    private boolean firstRun=true;
    public void run(){
      if (firstRun) {
        firstRun=false;
        try {
          peer.ping().addListener(this,MoreExecutors.sameThreadExecutor());
        }
 catch (        Exception e) {
          log.warn("String_Node_Str",peer,e.toString());
          return;
        }
        return;
      }
      final long interval=getPingIntervalMsec();
      if (interval <= 0)       return;
      pingTimer.schedule(new TimerTask(){
        @Override public void run(){
          try {
            if (!peers.contains(peer) || !PeerGroup.this.isRunning())             return;
            peer.ping().addListener(pingRunnable[0],MoreExecutors.sameThreadExecutor());
          }
 catch (          Exception e) {
            log.warn("String_Node_Str",peer,e.toString());
          }
        }
      }
,interval);
    }
  }
;
  pingRunnable[0].run();
}
Program: 85841
Project: 85841
Buggy source:
public static void write(FileChannel channel,StoredBlock block) throws IOException {
  ByteBuffer buf=ByteBuffer.allocate(Record.SIZE);
  buf.putInt(block.getHeight());
  byte[] chainWorkBytes=block.getChainWork().toByteArray();
  checkState(chainWorkBytes.length <= CHAIN_WORK_BYTES,"String_Node_Str");
  if (chainWorkBytes.length < CHAIN_WORK_BYTES) {
    buf.put(EMPTY_BYTES,0,CHAIN_WORK_BYTES - chainWorkBytes.length);
  }
  buf.put(chainWorkBytes);
  buf.put(block.getHeader().bitcoinSerialize());
  buf.position(0);
  channel.position(channel.size());
  if (channel.write(buf) < Record.SIZE)   throw new IOException("String_Node_Str");
  channel.position(channel.size() - Record.SIZE);
}

Fixed version (ground truth):
public static void write(FileChannel channel,StoredBlock block) throws IOException {
  ByteBuffer buf=ByteBuffer.allocate(Record.SIZE);
  buf.putInt(block.getHeight());
  byte[] chainWorkBytes=block.getChainWork().toByteArray();
  checkState(chainWorkBytes.length <= CHAIN_WORK_BYTES,"String_Node_Str");
  if (chainWorkBytes.length < CHAIN_WORK_BYTES) {
    buf.put(EMPTY_BYTES,0,CHAIN_WORK_BYTES - chainWorkBytes.length);
  }
  buf.put(chainWorkBytes);
  buf.put(block.getHeader().cloneAsHeader().bitcoinSerialize());
  buf.position(0);
  channel.position(channel.size());
  if (channel.write(buf) < Record.SIZE)   throw new IOException("String_Node_Str");
  channel.position(channel.size() - Record.SIZE);
}
Program: 85842
Project: 85842
Buggy source:
/** 
 * Returns the number of peers that have seen the given hash recently.
 */
public synchronized int numBroadcastPeers(Sha256Hash txHash){
  cleanPool();
  Entry entry=memoryPool.get(txHash);
  if (entry == null) {
    return 0;
  }
 else   if (entry.tx == null) {
    Preconditions.checkNotNull(entry.addresses);
    return entry.addresses.size();
  }
 else   if (entry.tx.get() == null) {
    memoryPool.remove(txHash);
    return 0;
  }
 else {
    Preconditions.checkState(entry.addresses == null);
    return entry.tx.get().getConfidence().numBroadcastPeers();
  }
}

Fixed version (ground truth):
/** 
 * Returns the number of peers that have seen the given hash recently.
 */
public synchronized int numBroadcastPeers(Sha256Hash txHash){
  cleanPool();
  Entry entry=memoryPool.get(txHash);
  if (entry == null) {
    return 0;
  }
 else   if (entry.tx == null) {
    Preconditions.checkNotNull(entry.addresses);
    return entry.addresses.size();
  }
 else {
    final Transaction tx=entry.tx.get();
    if (tx == null) {
      memoryPool.remove(txHash);
      return 0;
    }
 else {
      Preconditions.checkState(entry.addresses == null);
      return tx.getConfidence().numBroadcastPeers();
    }
  }
}
Program: 85843
Project: 85843
Buggy source:
public boolean hasUnspentOutputs(Sha256Hash hash,int numOutputs) throws BlockStoreException {
  for (int i=0; i < numOutputs; i++)   if (getTransactionOutput(hash,i) != null)   return true;
  return false;
}

Fixed version (ground truth):
public synchronized boolean hasUnspentOutputs(Sha256Hash hash,int numOutputs) throws BlockStoreException {
  for (int i=0; i < numOutputs; i++)   if (getTransactionOutput(hash,i) != null)   return true;
  return false;
}
Program: 85844
Project: 85844
Buggy source:
public StoredBlock getVerifiedChainHead() throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  return verifiedChainHead;
}

Fixed version (ground truth):
public synchronized StoredBlock getVerifiedChainHead() throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  return verifiedChainHead;
}
Program: 85845
Project: 85845
Buggy source:
public void setVerifiedChainHead(StoredBlock chainHead) throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  this.verifiedChainHead=chainHead;
  if (this.chainHead.getHeight() < chainHead.getHeight())   setChainHead(chainHead);
  fullBlockMap.removeByMultiKey(chainHead.getHeight() - fullStoreDepth);
}

Fixed version (ground truth):
public synchronized void setVerifiedChainHead(StoredBlock chainHead) throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  this.verifiedChainHead=chainHead;
  if (this.chainHead.getHeight() < chainHead.getHeight())   setChainHead(chainHead);
  fullBlockMap.removeByMultiKey(chainHead.getHeight() - fullStoreDepth);
}
Program: 85846
Project: 85846
Buggy source:
public StoredBlock getChainHead() throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  return chainHead;
}

Fixed version (ground truth):
public synchronized StoredBlock getChainHead() throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  return chainHead;
}
Program: 85847
Project: 85847
Buggy source:
public StoredBlock getOnceUndoableStoredBlock(Sha256Hash hash) throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  StoredBlockAndWasUndoableFlag storedBlock=blockMap.get(hash);
  return (storedBlock != null && storedBlock.wasUndoable) ? storedBlock.block : null;
}

Fixed version (ground truth):
public synchronized StoredBlock getOnceUndoableStoredBlock(Sha256Hash hash) throws BlockStoreException {
  Preconditions.checkNotNull(blockMap,"String_Node_Str");
  StoredBlockAndWasUndoableFlag storedBlock=blockMap.get(hash);
  return (storedBlock != null && storedBlock.wasUndoable) ? storedBlock.block : null;
}
Program: 85849
Project: 85849
Buggy source:
public VersionMessage(NetworkParameters params,int newBestHeight,boolean relayTxesBeforeFilter){
  super(params);
  clientVersion=NetworkParameters.PROTOCOL_VERSION;
  localServices=0;
  time=System.currentTimeMillis() / 1000;
  try {
    final byte[] localhost=new byte[]{127,0,0,1};
    myAddr=new PeerAddress(InetAddress.getByAddress(localhost),params.port,0);
    theirAddr=new PeerAddress(InetAddress.getByAddress(localhost),params.port,0);
  }
 catch (  UnknownHostException e) {
    throw new RuntimeException(e);
  }
  subVer=LIBRARY_SUBVER;
  bestHeight=newBestHeight;
  this.relayTxesBeforeFilter=relayTxesBeforeFilter;
  length=85;
  if (protocolVersion > 31402)   length+=8;
  length+=subVer == null ? 1 : VarInt.sizeOf(subVer.length()) + subVer.length();
}

Fixed version (ground truth):
public VersionMessage(NetworkParameters params,int newBestHeight,boolean relayTxesBeforeFilter){
  super(params);
  clientVersion=NetworkParameters.PROTOCOL_VERSION;
  localServices=0;
  time=System.currentTimeMillis() / 1000;
  try {
    final byte[] localhost=new byte[]{127,0,0,1};
    myAddr=new PeerAddress(InetAddress.getByAddress(localhost),params.port,0);
    theirAddr=new PeerAddress(InetAddress.getByAddress(localhost),params.port,0);
  }
 catch (  UnknownHostException e) {
    throw new RuntimeException(e);
  }
  subVer=LIBRARY_SUBVER;
  bestHeight=newBestHeight;
  this.relayTxesBeforeFilter=relayTxesBeforeFilter;
  length=85;
  if (protocolVersion > 31402)   length+=8;
  length+=VarInt.sizeOf(subVer.length()) + subVer.length();
}
Program: 85851
Project: 85851
Buggy source:
private void createTransientState(){
  eventListeners=new ArrayList<WalletEventListener>();
  ignoreNextNewBlock=new HashSet<Sha256Hash>();
  txConfidenceListener=new TransactionConfidence.Listener(){
    public void onConfidenceChanged(    Transaction tx){
      invokeOnTransactionConfidenceChanged(tx);
      invokeOnWalletChanged();
    }
  }
;
  acceptTimeLockedTransactions=false;
}

Fixed version (ground truth):
private synchronized void createTransientState(){
  eventListeners=new ArrayList<WalletEventListener>();
  ignoreNextNewBlock=new HashSet<Sha256Hash>();
  txConfidenceListener=new TransactionConfidence.Listener(){
    public void onConfidenceChanged(    Transaction tx){
      invokeOnTransactionConfidenceChanged(tx);
      invokeOnWalletChanged();
    }
  }
;
  acceptTimeLockedTransactions=false;
}