nus-yam/ex-repair huggingface dataset:
Program: 10930
Project: 10930
Buggy source:
@Override public boolean requestNewReceivingAddress(int hdAccountId){
  int issuedIndex=this.issuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH);
  final boolean[] result={false};
  if (issuedIndex > HDAccount.MaxUnusedNewAddressCount) {
    String sql="String_Node_Str" + "String_Node_Str";
    this.execQueryOneRecord(sql,new String[]{Integer.toString(hdAccountId),Integer.toString(issuedIndex - HDAccount.MaxUnusedNewAddressCount - 1),"String_Node_Str"},new Function<ICursor,Void>(){
      @Nullable @Override public Void apply(      @Nullable ICursor c){
        result[0]=c.getInt(0) > 0;
        return null;
      }
    }
);
  }
 else {
    result[0]=true;
  }
  if (result[0]) {
    this.updateIssuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH,issuedIndex + 1);
  }
  return result[0];
}

Fixed version (ground truth):
@Override public boolean requestNewReceivingAddress(int hdAccountId){
  int issuedIndex=this.issuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH);
  final boolean[] result={false};
  if (issuedIndex >= HDAccount.MaxUnusedNewAddressCount) {
    String sql="String_Node_Str" + "String_Node_Str";
    this.execQueryOneRecord(sql,new String[]{Integer.toString(hdAccountId),Integer.toString(issuedIndex - HDAccount.MaxUnusedNewAddressCount + 1),"String_Node_Str"},new Function<ICursor,Void>(){
      @Nullable @Override public Void apply(      @Nullable ICursor c){
        result[0]=c.getInt(0) > 0;
        return null;
      }
    }
);
  }
 else {
    result[0]=true;
  }
  if (result[0]) {
    this.updateIssuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH,issuedIndex + 1);
  }
  return result[0];
}
Program: 10931
Project: 10931
Buggy source:
@Override public boolean requestNewReceivingAddress(int hdAccountId){
  int issuedIndex=this.issuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH);
  final boolean[] result={false};
  if (issuedIndex >= HDAccount.MaxUnusedNewAddressCount) {
    String sql="String_Node_Str" + "String_Node_Str";
    this.execQueryOneRecord(sql,new String[]{Integer.toString(hdAccountId),Integer.toString(issuedIndex - HDAccount.MaxUnusedNewAddressCount + 1),"String_Node_Str"},new Function<ICursor,Void>(){
      @Nullable @Override public Void apply(      @Nullable ICursor c){
        result[0]=c.getInt(0) > 0;
        return null;
      }
    }
);
  }
 else {
    result[0]=true;
  }
  if (result[0]) {
    this.updateIssuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH,issuedIndex + 1);
  }
  return result[0];
}

Fixed version (ground truth):
@Override public boolean requestNewReceivingAddress(int hdAccountId){
  int issuedIndex=this.issuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH);
  final boolean[] result={false};
  if (issuedIndex >= HDAccount.MaxUnusedNewAddressCount - 2) {
    String sql="String_Node_Str" + "String_Node_Str";
    this.execQueryOneRecord(sql,new String[]{Integer.toString(hdAccountId),Integer.toString(issuedIndex - HDAccount.MaxUnusedNewAddressCount + 1),"String_Node_Str"},new Function<ICursor,Void>(){
      @Nullable @Override public Void apply(      @Nullable ICursor c){
        result[0]=c.getInt(0) > 0;
        return null;
      }
    }
);
  }
 else {
    result[0]=true;
  }
  if (result[0]) {
    this.updateIssuedIndex(hdAccountId,AbstractHD.PathType.EXTERNAL_ROOT_PATH,issuedIndex + 1);
  }
  return result[0];
}
Program: 10934
Project: 10934
Buggy source:
public List<Tx> compressTxsForHDAccount(List<Tx> txList){
  Map<Sha256Hash,Tx> txHashList=new HashMap<Sha256Hash,Tx>();
  for (  Tx tx : txList) {
    txHashList.put(new Sha256Hash(tx.getTxHash()),tx);
  }
  for (  Tx tx : txList) {
    if (!isSendFromHDAccount(tx,txHashList) && tx.getOuts().size() > BitherjSettings.COMPRESS_OUT_NUM) {
      List<Out> outList=new ArrayList<Out>();
      HashSet<String> addressHashSet=AbstractDb.hdAccountAddressProvider.getBelongAccountAddresses(tx.getOutAddressList());
      for (      Out out : tx.getOuts()) {
        if (addressHashSet.contains(out.getOutAddress())) {
          outList.add(out);
        }
      }
      tx.setOuts(outList);
    }
  }
  return txList;
}

Fixed version (ground truth):
public List<Tx> compressTxsForHDAccount(List<Tx> txList){
  Map<Sha256Hash,Tx> txHashList=new HashMap<Sha256Hash,Tx>();
  for (  Tx tx : txList) {
    txHashList.put(new Sha256Hash(tx.getTxHash()),tx);
    AbstractDb.hdAccountAddressProvider.updateOutHDAccountId(tx);
  }
  for (  Tx tx : txList) {
    if (!isSendFromHDAccount(tx,txHashList) && tx.getOuts().size() > BitherjSettings.COMPRESS_OUT_NUM) {
      List<Out> outList=new ArrayList<Out>();
      HashSet<String> addressHashSet=AbstractDb.hdAccountAddressProvider.getBelongAccountAddresses(tx.getOutAddressList());
      for (      Out out : tx.getOuts()) {
        if (addressHashSet.contains(out.getOutAddress())) {
          outList.add(out);
        }
      }
      tx.setOuts(outList);
    }
  }
  return txList;
}
Program: 10936
Project: 10936
Buggy source:
private boolean isSendFromHDAccount(Tx tx,Map<Sha256Hash,Tx> txHashList){
  List<String> inAddressList=new ArrayList<String>();
  for (  In in : tx.getIns()) {
    Sha256Hash prevTxHahs=new Sha256Hash(in.getPrevTxHash());
    if (txHashList.containsKey(prevTxHahs)) {
      Tx preTx=txHashList.get(prevTxHahs);
      for (      Out out : preTx.getOuts()) {
        if (out.getOutSn() == in.getPrevOutSn()) {
          inAddressList.add(out.getOutAddress());
        }
      }
    }
  }
  List<HDAccount.HDAccountAddress> hdAccountAddressList=AbstractDb.hdAccountAddressProvider.belongAccount(this.hdAccountHot.hdSeedId,inAddressList);
  return hdAccountAddressList.size() > 0;
}

Fixed version (ground truth):
private boolean isSendFromHDAccount(Tx tx,Map<Sha256Hash,Tx> txHashList){
  List<String> inAddressList=new ArrayList<String>();
  for (  In in : tx.getIns()) {
    Sha256Hash prevTxHahs=new Sha256Hash(in.getPrevTxHash());
    if (txHashList.containsKey(prevTxHahs)) {
      Tx preTx=txHashList.get(prevTxHahs);
      for (      Out out : preTx.getOuts()) {
        if (out.getOutSn() == in.getPrevOutSn()) {
          inAddressList.add(out.getOutAddress());
        }
      }
    }
  }
  return AbstractDb.hdAccountAddressProvider.getRelatedAddressCnt(inAddressList) > 0;
}
Program: 10938
Project: 10938
Buggy source:
private void initHDAccounts(){
  List<Integer> seeds=AbstractDb.addressProvider.getHDAccountSeeds();
  if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) {
    for (    int seedId : seeds) {
      if (hdAccountCold == null && AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
        hdAccountCold=new HDAccountCold(seedId);
      }
    }
  }
 else {
    for (    int seedId : seeds) {
      if (hdAccountHot == null && AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
        hdAccountHot=new HDAccount(seedId);
      }
 else       if (hdAccountMonitored == null && !AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
        hdAccountMonitored=new HDAccountMonitored(seedId);
      }
    }
  }
}

Fixed version (ground truth):
private void initHDAccounts(){
  if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.HOT) {
    List<Integer> seeds=AbstractDb.addressProvider.getHDAccountSeeds();
    for (    int seedId : seeds) {
      if (hdAccountHot == null && AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
        hdAccountHot=new HDAccount(seedId);
      }
 else       if (hdAccountMonitored == null && !AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
        hdAccountMonitored=new HDAccountMonitored(seedId);
      }
    }
  }
}
Program: 10939
Project: 10939
Buggy source:
public boolean hasHDAccountCold(){
synchronized (lock) {
    return hdAccountCold != null;
  }
}

Fixed version (ground truth):
public boolean hasHDAccountCold(){
synchronized (lock) {
    if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) {
      List<Integer> seeds=AbstractDb.addressProvider.getHDAccountSeeds();
      for (      int seedId : seeds) {
        if (AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
          return true;
        }
      }
    }
    return false;
  }
}
Program: 10940
Project: 10940
Buggy source:
public HDAccountCold getHDAccountCold(){
synchronized (lock) {
    return hdAccountCold;
  }
}

Fixed version (ground truth):
public HDAccountCold getHDAccountCold(){
synchronized (lock) {
    if (AbstractApp.bitherjSetting.getAppMode() == BitherjSettings.AppMode.COLD) {
      List<Integer> seeds=AbstractDb.addressProvider.getHDAccountSeeds();
      for (      int seedId : seeds) {
        if (AbstractDb.addressProvider.hasMnemonicSeed(seedId)) {
          return new HDAccountCold(seedId);
        }
      }
    }
    return null;
  }
}
Program: 10942
Project: 10942
Buggy source:
public void onNewTx(Tx tx,List<HDAccount.HDAccountAddress> relatedAddresses,Tx.TxNotificationType txNotificationType){
  if (relatedAddresses == null || relatedAddresses.size() == 0) {
    return;
  }
  int maxInternal=-1, maxExternal=-1;
  for (  HDAccount.HDAccountAddress a : relatedAddresses) {
    if (a.getPathType() == AbstractHD.PathType.EXTERNAL_ROOT_PATH) {
      if (a.getIndex() > maxExternal) {
        maxExternal=a.getIndex();
      }
    }
 else {
      if (a.getIndex() > maxInternal) {
        maxInternal=a.getIndex();
      }
    }
  }
  log.info("String_Node_Str",maxExternal,maxInternal);
  if (maxExternal >= 0 && maxExternal > issuedExternalIndex()) {
    updateIssuedExternalIndex(maxExternal);
  }
  if (maxInternal >= 0 && maxInternal > issuedInternalIndex()) {
    updateIssuedInternalIndex(maxInternal);
  }
  supplyEnoughKeys(true);
  long deltaBalance=getDeltaBalance();
  AbstractApp.notificationService.notificatTx(HDAccountMonitoredPlaceHolder,tx,txNotificationType,deltaBalance);
}

Fixed version (ground truth):
public void onNewTx(Tx tx,List<HDAccount.HDAccountAddress> relatedAddresses,Tx.TxNotificationType txNotificationType){
  supplyEnoughKeys(true);
  long deltaBalance=getDeltaBalance();
  AbstractApp.notificationService.notificatTx(HDAccountMonitoredPlaceHolder,tx,txNotificationType,deltaBalance);
}
Program: 10943
Project: 10943
Buggy source:
int addMonitoredHDAccount(boolean isXrandom,byte[] externalPub,byte[] internalPub);

Fixed version (ground truth):
int addMonitoredHDAccount(String firstAddress,boolean isXrandom,byte[] externalPub,byte[] internalPub);
Program: 10944
Project: 10944
Buggy source:
private void initFromDb(){
synchronized (addresses) {
    List<EnterpriseHDMAddress> temp=AbstractDb.enterpriseHDMProvider.getEnterpriseHDMAddress(EnterpriseHDMKeychain.this);
    if (temp != null) {
      addresses.addAll(temp);
    }
  }
}

Fixed version (ground truth):
private void initFromDb(){
  pubCount=AbstractDb.enterpriseHDMProvider.getPubCount();
  threshold=AbstractDb.enterpriseHDMProvider.getThreshold();
synchronized (addresses) {
    List<EnterpriseHDMAddress> temp=AbstractDb.enterpriseHDMProvider.getEnterpriseHDMAddress(EnterpriseHDMKeychain.this);
    if (temp != null) {
      addresses.addAll(temp);
    }
  }
}
Program: 10945
Project: 10945
Buggy source:
private void initAlias(){
  Map<String,String> addressAlias=AbstractDb.addressProvider.getAliases();
  if (addressAlias.size() == 0) {
    return;
  }
  for (  Address address : privKeyAddresses) {
    String alias=addressAlias.get(address.getAddress());
    address.setAlias(alias);
  }
  for (  Address address : watchOnlyAddresses) {
    String alias=addressAlias.get(address.getAddress());
    address.setAlias(alias);
  }
  for (  HDMAddress address : hdmKeychain.getAllCompletedAddresses()) {
    String alias=addressAlias.get(address.getAddress());
    address.setAlias(alias);
  }
}

Fixed version (ground truth):
private void initAlias(){
  Map<String,String> addressAlias=AbstractDb.addressProvider.getAliases();
  if (addressAlias.size() == 0) {
    return;
  }
  for (  Address address : privKeyAddresses) {
    if (addressAlias.containsKey(address.getAddress())) {
      String alias=addressAlias.get(address.getAddress());
      address.setAlias(alias);
    }
  }
  for (  Address address : watchOnlyAddresses) {
    if (addressAlias.containsKey(address.getAddress())) {
      String alias=addressAlias.get(address.getAddress());
      address.setAlias(alias);
    }
  }
  if (hdmKeychain != null) {
    for (    HDMAddress address : hdmKeychain.getAllCompletedAddresses()) {
      if (addressAlias.containsKey(address.getAddress())) {
        String alias=addressAlias.get(address.getAddress());
        address.setAlias(alias);
      }
    }
  }
}
Program: 10947
Project: 10947
Buggy source:
public boolean checkRValuesForTx(Tx tx){
  HashSet<BigInteger> rs=new HashSet<BigInteger>();
  for (  In in : AbstractDb.txProvider.getRelatedIn(this.address)) {
    if (in.getInSignature() != null) {
      Script script=new Script(in.getInSignature());
      if (script.getFromAddress().equals(this.address)) {
        for (        byte[] data : script.getSigs()) {
          TransactionSignature signature=TransactionSignature.decodeFromBitcoin(data,false);
          rs.add(new BigInteger(signature.r.toByteArray()));
        }
      }
    }
  }
  for (  In in : tx.getIns()) {
    Script script=new Script(in.getInSignature());
    for (    byte[] data : script.getSigs()) {
      TransactionSignature signature=TransactionSignature.decodeFromBitcoin(data,false);
      BigInteger i=new BigInteger(signature.r.toByteArray());
      if (rs.contains(i))       return false;
      rs.add(i);
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean checkRValuesForTx(Tx tx){
  HashSet<BigInteger> rs=new HashSet<BigInteger>();
  for (  In in : AbstractDb.txProvider.getRelatedIn(this.address)) {
    if (in.getInSignature() != null && !in.isCoinBase()) {
      Script script=new Script(in.getInSignature());
      if (script.getFromAddress().equals(this.address)) {
        for (        byte[] data : script.getSigs()) {
          TransactionSignature signature=TransactionSignature.decodeFromBitcoin(data,false);
          rs.add(new BigInteger(signature.r.toByteArray()));
        }
      }
    }
  }
  for (  In in : tx.getIns()) {
    Script script=new Script(in.getInSignature());
    for (    byte[] data : script.getSigs()) {
      TransactionSignature signature=TransactionSignature.decodeFromBitcoin(data,false);
      BigInteger i=new BigInteger(signature.r.toByteArray());
      if (rs.contains(i))       return false;
      rs.add(i);
    }
  }
  return true;
}
Program: 10948
Project: 10948
Buggy source:
public boolean checkRValues(){
  HashSet<BigInteger> rs=new HashSet<BigInteger>();
  for (  In in : AbstractDb.txProvider.getRelatedIn(this.address)) {
    if (in.getInSignature() != null) {
      Script script=new Script(in.getInSignature());
      if (script.getFromAddress().equals(this.address)) {
        for (        byte[] data : script.getSigs()) {
          TransactionSignature signature=TransactionSignature.decodeFromBitcoin(data,false);
          BigInteger i=new BigInteger(signature.r.toByteArray());
          if (rs.contains(i))           return false;
          rs.add(i);
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean checkRValues(){
  HashSet<BigInteger> rs=new HashSet<BigInteger>();
  for (  In in : AbstractDb.txProvider.getRelatedIn(this.address)) {
    if (in.getInSignature() != null && !in.isCoinBase()) {
      Script script=new Script(in.getInSignature());
      if (script.getFromAddress().equals(this.address)) {
        for (        byte[] data : script.getSigs()) {
          TransactionSignature signature=TransactionSignature.decodeFromBitcoin(data,false);
          BigInteger i=new BigInteger(signature.r.toByteArray());
          if (rs.contains(i))           return false;
          rs.add(i);
        }
      }
    }
  }
  return true;
}
Program: 10949
Project: 10949
Buggy source:
public String getFromAddress(){
  if (getConnectedOut() != null) {
    return getConnectedOut().getOutAddress();
  }
 else   if (this.getInSignature() != null) {
    Script script=new Script(this.getInSignature());
    return script.getFromAddress();
  }
  return null;
}

Fixed version (ground truth):
public String getFromAddress(){
  if (getConnectedOut() != null) {
    return getConnectedOut().getOutAddress();
  }
 else   if (this.getInSignature() != null && !this.isCoinBase()) {
    Script script=new Script(this.getInSignature());
    return script.getFromAddress();
  }
  return null;
}
Program: 10950
Project: 10950
Buggy source:
private byte[] getSignPubs(byte[] messageHash,ECKey.ECDSASignature sig,List<byte[]> pubs){
  for (int i=0; i < 4; i++) {
    ECPoint point=ECKey.recoverECPointFromSignature(i,sig,messageHash);
    ECKey ecKeyCompress=new ECKey(null,point.getEncoded(true));
    ECKey ecKeyUnCompress=new ECKey(null,point.getEncoded(false));
    for (int j=0; j < pubs.size(); i++) {
      if (Arrays.equals(ecKeyCompress.getPubKey(),pubs.get(j))) {
        return ecKeyCompress.getPubKey();
      }
      if (Arrays.equals(ecKeyUnCompress.getPubKey(),pubs.get(j))) {
        return ecKeyUnCompress.getPubKey();
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private byte[] getSignPubs(byte[] messageHash,ECKey.ECDSASignature sig,List<byte[]> pubs){
  for (int i=0; i < 4; i++) {
    ECPoint point=ECKey.recoverECPointFromSignature(i,sig,messageHash);
    ECKey ecKeyCompress=new ECKey(null,point.getEncoded(true));
    ECKey ecKeyUnCompress=new ECKey(null,point.getEncoded(false));
    for (int j=0; j < pubs.size(); j++) {
      if (Arrays.equals(ecKeyCompress.getPubKey(),pubs.get(j))) {
        return ecKeyCompress.getPubKey();
      }
      if (Arrays.equals(ecKeyUnCompress.getPubKey(),pubs.get(j))) {
        return ecKeyUnCompress.getPubKey();
      }
    }
  }
  return null;
}
Program: 10951
Project: 10951
Buggy source:
public List<Tx> compressTxsForApi(List<Tx> txList,Address address){
  List<Sha256Hash> txHashList=new ArrayList<Sha256Hash>();
  for (  Tx tx : txList) {
    txHashList.add(new Sha256Hash(tx.getTxHash()));
  }
  for (  Tx tx : txList) {
    if (!isSendFromMe(tx,txHashList) && tx.getOuts().size() > BitherjSettings.COMPRESS_OUT_NUM) {
      List<Out> outList=new ArrayList<Out>();
      for (      Out out : tx.getOuts()) {
        if (Utils.compareString(address.getAddress(),out.getOutAddress())) {
          outList.add(out);
        }
      }
      tx.setOuts(outList);
    }
  }
  return txList;
}

Fixed version (ground truth):
public List<Tx> compressTxsForApi(List<Tx> txList,Address address){
  Map<Sha256Hash,Tx> txHashList=new HashMap<Sha256Hash,Tx>();
  for (  Tx tx : txList) {
    txHashList.put(new Sha256Hash(tx.getTxHash()),tx);
  }
  for (  Tx tx : txList) {
    if (!isSendFromMe(tx,txHashList,address) && tx.getOuts().size() > BitherjSettings.COMPRESS_OUT_NUM) {
      List<Out> outList=new ArrayList<Out>();
      for (      Out out : tx.getOuts()) {
        if (Utils.compareString(address.getAddress(),out.getOutAddress())) {
          outList.add(out);
        }
      }
      tx.setOuts(outList);
    }
  }
  return txList;
}
Program: 10952
Project: 10952
Buggy source:
public long deltaAmountFrom(Address address){
  long receive=0;
  long sent=0;
  for (  Out out : this.outs) {
    if (Utils.compareString(address.getAddress(),out.getOutAddress())) {
      receive+=out.getOutValue();
    }
  }
  for (  In in : this.ins) {
    Tx tx=AbstractDb.txProvider.getTxDetailByTxHash(in.getPrevTxHash());
    if (tx != null) {
      int n=in.getPrevOutSn();
      if (n < tx.outs.size()) {
        if (Utils.compareString(address.getAddress(),tx.outs.get(n).getOutAddress())) {
          sent+=tx.outs.get(n).getOutValue();
        }
      }
 else {
        for (        Out out : tx.outs) {
          if (Utils.compareString(address.getAddress(),out.getOutAddress())) {
            sent+=out.getOutValue();
          }
        }
      }
    }
  }
  return receive - sent;
}

Fixed version (ground truth):
public long deltaAmountFrom(Address address){
  long receive=0;
  long sent=0;
  for (  Out out : this.outs) {
    if (Utils.compareString(address.getAddress(),out.getOutAddress())) {
      receive+=out.getOutValue();
    }
  }
  for (  In in : this.ins) {
    Tx tx=AbstractDb.txProvider.getTxDetailByTxHash(in.getPrevTxHash());
    if (tx != null) {
      int n=in.getPrevOutSn();
      for (      Out out : tx.outs) {
        if (Utils.compareString(address.getAddress(),out.getOutAddress()) && n == out.getOutSn()) {
          sent+=out.getOutValue();
        }
      }
    }
  }
  return receive - sent;
}
Program: 10954
Project: 10954
Buggy source:
public Tx compressTx(Tx tx){
  List<Out> outList=new ArrayList<Out>();
  if (!isSendFromMe(tx) && tx.getOuts().size() > BitherjSettings.COMPRESS_OUT_NUM) {
    for (    Out out : tx.getOuts()) {
      String outAddress=out.getOutAddress();
      if (addressHashSet.contains(outAddress)) {
        outList.add(out);
      }
    }
  }
  tx.setOuts(outList);
  return tx;
}

Fixed version (ground truth):
public Tx compressTx(Tx tx){
  if (!isSendFromMe(tx) && tx.getOuts().size() > BitherjSettings.COMPRESS_OUT_NUM) {
    List<Out> outList=new ArrayList<Out>();
    for (    Out out : tx.getOuts()) {
      String outAddress=out.getOutAddress();
      if (addressHashSet.contains(outAddress)) {
        outList.add(out);
      }
    }
    tx.setOuts(outList);
  }
  return tx;
}
Program: 10955
Project: 10955
Buggy source:
public long getFee(){
  long amount=0;
  for (  In in : getIns()) {
    Tx preTx=AbstractDb.txProvider.getTxDetailByTxHash(in.getPrevTxHash());
    boolean hasOut=false;
    for (    Out out : preTx.getOuts()) {
      if (in.getPrevOutSn() == out.getOutSn()) {
        amount+=preTx.getOuts().get(in.getPrevOutSn()).getOutValue();
        hasOut=true;
      }
    }
    if (!hasOut) {
      return Long.MAX_VALUE;
    }
  }
  for (  Out out : getOuts()) {
    amount-=out.getOutValue();
  }
  return amount;
}

Fixed version (ground truth):
public long getFee(){
  long amount=0;
  for (  In in : getIns()) {
    Tx preTx=AbstractDb.txProvider.getTxDetailByTxHash(in.getPrevTxHash());
    boolean hasOut=false;
    for (    Out out : preTx.getOuts()) {
      if (in.getPrevOutSn() == out.getOutSn()) {
        amount+=out.getOutValue();
        hasOut=true;
      }
    }
    if (!hasOut) {
      return Long.MAX_VALUE;
    }
  }
  for (  Out out : getOuts()) {
    amount-=out.getOutValue();
  }
  return amount;
}
Program: 10956
Project: 10956
Buggy source:
public int compare(Out out1,Out out2){
  int depth1=0;
  int depth2=0;
  long coinDepth1=BlockChain.getInstance().lastBlock.getBlockNo() * out1.getOutValue() - out1.getCoinDepth() + out1.getOutValue();
  long coinDepth2=BlockChain.getInstance().lastBlock.getBlockNo() * out2.getOutValue() - out2.getCoinDepth() + out2.getOutValue();
  if (coinDepth1 != coinDepth2) {
    return (int)(coinDepth1 - coinDepth2);
  }
 else {
    BigInteger hash1=new BigInteger(1,out1.getTxHash());
    BigInteger hash2=new BigInteger(1,out2.getTxHash());
    int result=hash1.compareTo(hash2);
    if (result != 0) {
      return result;
    }
 else {
      return out1.getOutSn() - out2.getOutSn();
    }
  }
}

Fixed version (ground truth):
public int compare(Out out1,Out out2){
  int depth1=0;
  int depth2=0;
  long coinDepth1=BlockChain.getInstance().lastBlock.getBlockNo() * out1.getOutValue() - out1.getCoinDepth() + out1.getOutValue();
  long coinDepth2=BlockChain.getInstance().lastBlock.getBlockNo() * out2.getOutValue() - out2.getCoinDepth() + out2.getOutValue();
  if (coinDepth1 != coinDepth2) {
    if (coinDepth2 > coinDepth1)     return 1;
 else     return -1;
  }
 else   if (out1.getOutValue() != out2.getOutValue()) {
    if (out2.getOutValue() > out1.getOutValue())     return 1;
 else     return -1;
  }
 else {
    BigInteger hash1=new BigInteger(1,out1.getTxHash());
    BigInteger hash2=new BigInteger(1,out2.getTxHash());
    int result=hash1.compareTo(hash2);
    if (result != 0) {
      return result;
    }
 else {
      return out1.getOutSn() - out2.getOutSn();
    }
  }
}
Program: 10959
Project: 10959
Buggy source:
public int relayedBlocks(List<Block> blocks) throws VerificationException {
  if (blocks == null || blocks.size() == 0) {
    return 0;
  }
  Block prev=null;
  Block first=blocks.get(0);
  int rollbackBlockNo=0;
  if (Arrays.equals(first.getBlockPrev(),this.getLastBlock().getBlockHash())) {
    prev=this.getLastBlock();
  }
 else   if (BlockProvider.getInstance().getMainChainBlock(first.getBlockPrev()) != null) {
    prev=this.getSameParent(first,this.getLastBlock());
    rollbackBlockNo=prev.getBlockNo();
  }
  if (prev == null) {
    return 0;
  }
  for (  Block block : blocks) {
    if (!Arrays.equals(block.getBlockPrev(),prev.getBlockHash())) {
      return 0;
    }
    block.setBlockNo(prev.getBlockNo() + 1);
    try {
      block.verifyDifficultyFromPreviousBlock(prev);
    }
 catch (    Exception e) {
      e.printStackTrace();
      break;
    }
    block.setMain(true);
    prev=block;
  }
  if (rollbackBlockNo > 0) {
    this.rollbackBlock(rollbackBlockNo);
  }
  this.addBlocks(blocks);
  for (  Block block : blocks) {
    TxProvider.getInstance().confirmTx(block.getBlockNo(),block.getTxHashes());
  }
  this.lastBlock=blocks.get(blocks.size() - 1);
  return blocks.size();
}

Fixed version (ground truth):
public int relayedBlocks(List<Block> blocks) throws VerificationException {
  if (blocks == null || blocks.size() == 0) {
    return 0;
  }
  Block prev=null;
  Block first=blocks.get(0);
  int rollbackBlockNo=0;
  if (Arrays.equals(first.getBlockPrev(),this.getLastBlock().getBlockHash())) {
    prev=this.getLastBlock();
  }
 else   if (BlockProvider.getInstance().getMainChainBlock(first.getBlockPrev()) != null) {
    prev=this.getSameParent(first,this.getLastBlock());
    rollbackBlockNo=prev.getBlockNo();
  }
  if (prev == null) {
    return 0;
  }
  for (  Block block : blocks) {
    if (!Arrays.equals(block.getBlockPrev(),prev.getBlockHash())) {
      return 0;
    }
    block.setBlockNo(prev.getBlockNo() + 1);
    try {
      int transitionTime=0;
      if (block.getBlockNo() % BitherjSettings.BLOCK_DIFFICULTY_INTERVAL == 0) {
        long now=System.currentTimeMillis();
        Block cursor=first;
        for (int i=0; i < BitherjSettings.BLOCK_DIFFICULTY_INTERVAL - block.getBlockNo() + first.getBlockNo(); i++) {
          if (cursor == null) {
            throw new VerificationException("String_Node_Str");
          }
          cursor=getBlock(cursor.getBlockPrev());
        }
        long elapsed=System.currentTimeMillis() - now;
        if (elapsed > 50)         log.info("String_Node_Str",elapsed);
        transitionTime=cursor.getBlockTime();
      }
      block.verifyDifficultyFromPreviousBlock(prev,transitionTime);
    }
 catch (    Exception e) {
      e.printStackTrace();
      return 0;
    }
    block.setMain(true);
    prev=block;
  }
  if (rollbackBlockNo > 0) {
    this.rollbackBlock(rollbackBlockNo);
  }
  this.addBlocks(blocks);
  for (  Block block : blocks) {
    TxProvider.getInstance().confirmTx(block.getBlockNo(),block.getTxHashes());
  }
  this.lastBlock=blocks.get(blocks.size() - 1);
  return blocks.size();
}
Program: 10960
Project: 10960
Buggy source:
public int relayedBlocks(List<Block> blocks) throws VerificationException {
  if (blocks == null || blocks.size() == 0) {
    return 0;
  }
  Block prev=null;
  Block first=blocks.get(0);
  int rollbackBlockNo=0;
  if (Arrays.equals(first.getBlockPrev(),this.getLastBlock().getBlockHash())) {
    prev=this.getLastBlock();
  }
 else   if (BlockProvider.getInstance().getMainChainBlock(first.getBlockPrev()) != null) {
    prev=this.getSameParent(this.getLastBlock(),first);
    rollbackBlockNo=prev.getBlockNo();
  }
  if (prev == null) {
    return 0;
  }
  for (  Block block : blocks) {
    if (!Arrays.equals(block.getBlockPrev(),prev.getBlockHash())) {
      return 0;
    }
    block.setBlockNo(prev.getBlockNo() + 1);
    try {
      block.verifyDifficultyFromPreviousBlock(prev);
    }
 catch (    Exception e) {
      e.printStackTrace();
      break;
    }
    block.setMain(true);
    prev=block;
  }
  if (rollbackBlockNo > 0) {
    this.rollbackBlock(rollbackBlockNo);
  }
  this.addBlocks(blocks);
  for (  Block block : blocks) {
    TxProvider.getInstance().confirmTx(block.getBlockNo(),block.getTxHashes());
  }
  this.lastBlock=blocks.get(blocks.size() - 1);
  return blocks.size();
}

Fixed version (ground truth):
public int relayedBlocks(List<Block> blocks) throws VerificationException {
  if (blocks == null || blocks.size() == 0) {
    return 0;
  }
  Block prev=null;
  Block first=blocks.get(0);
  int rollbackBlockNo=0;
  if (Arrays.equals(first.getBlockPrev(),this.getLastBlock().getBlockHash())) {
    prev=this.getLastBlock();
  }
 else   if (BlockProvider.getInstance().getMainChainBlock(first.getBlockPrev()) != null) {
    prev=this.getSameParent(first,this.getLastBlock());
    rollbackBlockNo=prev.getBlockNo();
  }
  if (prev == null) {
    return 0;
  }
  for (  Block block : blocks) {
    if (!Arrays.equals(block.getBlockPrev(),prev.getBlockHash())) {
      return 0;
    }
    block.setBlockNo(prev.getBlockNo() + 1);
    try {
      block.verifyDifficultyFromPreviousBlock(prev);
    }
 catch (    Exception e) {
      e.printStackTrace();
      break;
    }
    block.setMain(true);
    prev=block;
  }
  if (rollbackBlockNo > 0) {
    this.rollbackBlock(rollbackBlockNo);
  }
  this.addBlocks(blocks);
  for (  Block block : blocks) {
    TxProvider.getInstance().confirmTx(block.getBlockNo(),block.getTxHashes());
  }
  this.lastBlock=blocks.get(blocks.size() - 1);
  return blocks.size();
}
Program: 10961
Project: 10961
Buggy source:
public int relayedBlocks(List<Block> blocks) throws VerificationException {
  if (blocks == null || blocks.size() == 0) {
    return 0;
  }
  Block prev=null;
  Block first=blocks.get(0);
  int rollbackBlockNo=0;
  if (Arrays.equals(first.getBlockPrev(),this.getLastBlock().getBlockHash())) {
    prev=this.getLastBlock();
  }
 else   if (BlockProvider.getInstance().getMainChainBlock(first.getBlockHash()) != null) {
    prev=this.getSameParent(this.getLastBlock(),first);
    rollbackBlockNo=prev.getBlockNo();
  }
  if (prev == null) {
    return 0;
  }
  for (  Block block : blocks) {
    if (!Arrays.equals(block.getBlockPrev(),prev.getBlockHash())) {
      return 0;
    }
    block.setBlockNo(prev.getBlockNo() + 1);
    try {
      block.verifyDifficultyFromPreviousBlock(prev);
    }
 catch (    Exception e) {
      e.printStackTrace();
      break;
    }
    block.setMain(true);
    prev=block;
  }
  if (rollbackBlockNo > 0) {
    this.rollbackBlock(rollbackBlockNo);
  }
  this.addBlocks(blocks);
  for (  Block block : blocks) {
    TxProvider.getInstance().confirmTx(block.getBlockNo(),block.getTxHashes());
  }
  this.lastBlock=blocks.get(blocks.size() - 1);
  return blocks.size();
}

Fixed version (ground truth):
public int relayedBlocks(List<Block> blocks) throws VerificationException {
  if (blocks == null || blocks.size() == 0) {
    return 0;
  }
  Block prev=null;
  Block first=blocks.get(0);
  int rollbackBlockNo=0;
  if (Arrays.equals(first.getBlockPrev(),this.getLastBlock().getBlockHash())) {
    prev=this.getLastBlock();
  }
 else   if (BlockProvider.getInstance().getMainChainBlock(first.getBlockPrev()) != null) {
    prev=this.getSameParent(this.getLastBlock(),first);
    rollbackBlockNo=prev.getBlockNo();
  }
  if (prev == null) {
    return 0;
  }
  for (  Block block : blocks) {
    if (!Arrays.equals(block.getBlockPrev(),prev.getBlockHash())) {
      return 0;
    }
    block.setBlockNo(prev.getBlockNo() + 1);
    try {
      block.verifyDifficultyFromPreviousBlock(prev);
    }
 catch (    Exception e) {
      e.printStackTrace();
      break;
    }
    block.setMain(true);
    prev=block;
  }
  if (rollbackBlockNo > 0) {
    this.rollbackBlock(rollbackBlockNo);
  }
  this.addBlocks(blocks);
  for (  Block block : blocks) {
    TxProvider.getInstance().confirmTx(block.getBlockNo(),block.getTxHashes());
  }
  this.lastBlock=blocks.get(blocks.size() - 1);
  return blocks.size();
}
Program: 10962
Project: 10962
Buggy source:
private Block getSameParent(Block block1,Block block2){
  Block b1=block1;
  Block b2=block2;
  while (b1 != null && b2 != null && b1.getBlockHash() != b2.getBlockHash()) {
    b1=BlockProvider.getInstance().getBlock(b1.getBlockPrev());
    if (b1.getBlockNo() < b2.getBlockNo()) {
      b2=BlockProvider.getInstance().getBlock(b2.getBlockPrev());
    }
  }
  return b1;
}

Fixed version (ground truth):
private Block getSameParent(Block block1,Block block2){
  Block b1=block1;
  Block b2=block2;
  while (b1 != null && b2 != null && !Arrays.equals(b1.getBlockHash(),b2.getBlockHash())) {
    b1=BlockProvider.getInstance().getBlock(b1.getBlockPrev());
    if (b1.getBlockNo() < b2.getBlockNo()) {
      b2=BlockProvider.getInstance().getBlock(b2.getBlockPrev());
    }
  }
  return b1;
}
Program: 10963
Project: 10963
Buggy source:
private void checkMerkleRoot() throws VerificationException {
  byte[] calculatedRoot=calculateMerkleRoot();
  if (calculatedRoot != blockRoot) {
    log.error("String_Node_Str");
    throw new VerificationException("String_Node_Str" + Utils.bytesToHexString(calculatedRoot) + "String_Node_Str"+ Utils.bytesToHexString(blockRoot));
  }
}

Fixed version (ground truth):
private void checkMerkleRoot() throws VerificationException {
  byte[] calculatedRoot=calculateMerkleRoot();
  if (!Arrays.equals(calculatedRoot,blockRoot)) {
    log.error("String_Node_Str");
    throw new VerificationException("String_Node_Str" + Utils.bytesToHexString(calculatedRoot) + "String_Node_Str"+ Utils.bytesToHexString(blockRoot));
  }
}
Program: 10964
Project: 10964
Buggy source:
private void forkMainChain(Block forkStartBlock,Block lastBlock){
  Block b=this.lastBlock;
  Block next=lastBlock;
  while (b.getBlockHash() != forkStartBlock.getBlockHash()) {
    next=BlockProvider.getInstance().getOrphanBlockByPrevHash(b.getBlockPrev());
    BlockProvider.getInstance().updateBlock(b.getBlockHash(),false);
    b=BlockProvider.getInstance().getMainChainBlock(b.getBlockPrev());
    this.lastBlock=b;
  }
  b=next;
  BlockProvider.getInstance().updateBlock(next.getBlockHash(),true);
  this.lastBlock=next;
  while (b.getBlockHash() != lastBlock.getBlockPrev()) {
    BlockProvider.getInstance().updateBlock(b.getBlockHash(),true);
    this.lastBlock=b;
    b=BlockProvider.getInstance().getOrphanBlockByPrevHash(b.getBlockHash());
  }
  lastBlock.setMain(true);
  this.addBlock(lastBlock);
  this.lastBlock=lastBlock;
}

Fixed version (ground truth):
private void forkMainChain(Block forkStartBlock,Block lastBlock){
  Block b=this.lastBlock;
  Block next=lastBlock;
  while (!Arrays.equals(b.getBlockHash(),forkStartBlock.getBlockHash())) {
    next=BlockProvider.getInstance().getOrphanBlockByPrevHash(b.getBlockPrev());
    BlockProvider.getInstance().updateBlock(b.getBlockHash(),false);
    b=BlockProvider.getInstance().getMainChainBlock(b.getBlockPrev());
    this.lastBlock=b;
  }
  b=next;
  BlockProvider.getInstance().updateBlock(next.getBlockHash(),true);
  this.lastBlock=next;
  while (!Arrays.equals(b.getBlockHash(),lastBlock.getBlockPrev())) {
    BlockProvider.getInstance().updateBlock(b.getBlockHash(),true);
    this.lastBlock=b;
    b=BlockProvider.getInstance().getOrphanBlockByPrevHash(b.getBlockHash());
  }
  lastBlock.setMain(true);
  this.addBlock(lastBlock);
  this.lastBlock=lastBlock;
}
Program: 10965
Project: 10965
Buggy source:
/** 
 * Handle a single   {@link StreamingRecognitionResult} by creatinga  {@link TranscriptionResult} based on the result and notifying allall registered  {@link TranscriptionListener}s
 * @param result the result to handle
 */
private void handleResult(StreamingRecognitionResult result){
  List<SpeechRecognitionAlternative> alternatives=result.getAlternativesList();
  if (alternatives.isEmpty()) {
    return;
  }
  TranscriptionResult transcriptionResult=new TranscriptionResult(null,requestManager.getCurrentMessageID(),!result.getIsFinal(),requestManager.getLanguageTag(),result.getStability());
  for (  SpeechRecognitionAlternative alternative : alternatives) {
    transcriptionResult.addAlternative(new TranscriptionAlternative(alternative.getTranscript(),alternative.getConfidence()));
  }
  sent(transcriptionResult);
}

Fixed version (ground truth):
/** 
 * Handle a single   {@link StreamingRecognitionResult} by creatinga  {@link TranscriptionResult} based on the result and notifying allall registered  {@link TranscriptionListener}s
 * @param result the result to handle
 */
private void handleResult(StreamingRecognitionResult result){
  List<SpeechRecognitionAlternative> alternatives=result.getAlternativesList();
  if (alternatives.isEmpty()) {
    return;
  }
  TranscriptionResult transcriptionResult=new TranscriptionResult(null,this.messageID,!result.getIsFinal(),this.languageTag,result.getStability());
  for (  SpeechRecognitionAlternative alternative : alternatives) {
    transcriptionResult.addAlternative(new TranscriptionAlternative(alternative.getTranscript(),alternative.getConfidence()));
  }
  sent(transcriptionResult);
}
Program: 10966
Project: 10966
Buggy source:
@Override public void addTranscriptionListener(TranscriptionListener listener){
  requestManager.getResponseObserver().addListener(listener);
}

Fixed version (ground truth):
@Override public void addTranscriptionListener(TranscriptionListener listener){
  requestManager.addListener(listener);
}
Program: 10967
Project: 10967
Buggy source:
/** 
 * Create a ResponseApiStreamingObserver which listens for transcription results
 * @param manager the manager of requests
 */
ResponseApiStreamingObserver(RequestApiStreamObserverManager manager){
  requestManager=manager;
}

Fixed version (ground truth):
/** 
 * Create a ResponseApiStreamingObserver which listens for transcription results
 * @param manager the manager of requests
 */
ResponseApiStreamingObserver(RequestApiStreamObserverManager manager,String languageTag){
  this.requestManager=manager;
  this.languageTag=languageTag;
  messageID=UUID.randomUUID();
}
Program: 10968
Project: 10968
Buggy source:
/** 
 * Create a new RequestApiStreamObserverManager, which will try to mimic a streaming session of indefinite lenth
 * @param client the SpeechClient with which to open new sessions
 */
RequestApiStreamObserverManager(SpeechClient client){
  this.client=client;
  this.responseObserver=new ResponseApiStreamingObserver<>(this);
}

Fixed version (ground truth):
/** 
 * Create a new RequestApiStreamObserverManager, which will try to mimic a streaming session of indefinite lenth
 * @param client the SpeechClient with which to open new sessions
 */
RequestApiStreamObserverManager(SpeechClient client){
  this.client=client;
}
Program: 10969
Project: 10969
Buggy source:
@Override public void onCompleted(){
  for (  TranscriptionListener listener : listeners) {
    listener.completed();
  }
}

Fixed version (ground truth):
@Override public void onCompleted(){
  for (  TranscriptionListener listener : requestManager.getListeners()) {
    listener.completed();
  }
}
Program: 10970
Project: 10970
Buggy source:
/** 
 * Send a TranscriptionResult to each TranscriptionListener
 * @param result the result to sent
 */
private void sent(TranscriptionResult result){
  for (  TranscriptionListener listener : listeners) {
    listener.notify(result);
  }
  if (!result.isInterim()) {
    ActionServicesHandler.getInstance().notifyActionServices(result);
  }
}

Fixed version (ground truth):
/** 
 * Send a TranscriptionResult to each TranscriptionListener
 * @param result the result to sent
 */
private void sent(TranscriptionResult result){
  for (  TranscriptionListener listener : requestManager.getListeners()) {
    listener.notify(result);
  }
  if (!result.isInterim()) {
    ActionServicesHandler.getInstance().notifyActionServices(result);
  }
}
Program: 10971
Project: 10971
Buggy source:
@Override public void onNext(StreamingRecognizeResponse message){
  if (logger.isDebugEnabled())   logger.debug("String_Node_Str");
  if (message.hasError()) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + message.getError().getMessage());
    requestManager.terminateCurrentSession();
    return;
  }
  if (message.getResultsCount() == 0) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    requestManager.terminateCurrentSession();
    return;
  }
  List<StreamingRecognitionResult> results=message.getResultsList();
  StreamingRecognitionResult finalResult=results.get(0);
  if (!finalResult.getIsFinal()) {
    for (    StreamingRecognitionResult interimResult : results) {
      handleResult(interimResult);
    }
    return;
  }
  List<SpeechRecognitionAlternative> alternatives=finalResult.getAlternativesList();
  if (alternatives.isEmpty()) {
    logger.warn("String_Node_Str" + "String_Node_Str");
    requestManager.terminateCurrentSession();
    return;
  }
  handleResult(finalResult);
  requestManager.terminateCurrentSession();
}

Fixed version (ground truth):
@Override public void onNext(StreamingRecognizeResponse message){
  if (logger.isDebugEnabled())   logger.debug("String_Node_Str");
  if (message.hasError()) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + message.getError().getMessage());
    requestManager.terminateCurrentSession();
    return;
  }
  if (isEndOfSingleUtteranceMessage(message) || message.getResultsCount() == 0) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str");
    requestManager.terminateCurrentSession();
    return;
  }
  List<StreamingRecognitionResult> results=message.getResultsList();
  StreamingRecognitionResult finalResult=results.get(0);
  if (!finalResult.getIsFinal()) {
    for (    StreamingRecognitionResult interimResult : results) {
      handleResult(interimResult);
    }
    return;
  }
  List<SpeechRecognitionAlternative> alternatives=finalResult.getAlternativesList();
  if (alternatives.isEmpty()) {
    logger.warn("String_Node_Str" + "String_Node_Str");
    requestManager.terminateCurrentSession();
    return;
  }
  handleResult(finalResult);
  requestManager.terminateCurrentSession();
}
Program: 10972
Project: 10972
Buggy source:
/** 
 * Create a new ApiStreamObserver by instantiating it and sending the first request, which contains the configuration
 * @param config the configuration of the session
 * @return the ApiStreamObserver
 */
private ApiStreamObserver<StreamingRecognizeRequest> createObserver(RecognitionConfig config){
  this.messageID=UUID.randomUUID();
  this.languageTag=config.getLanguageCode();
  StreamingRecognitionConfig streamingRecognitionConfig=StreamingRecognitionConfig.newBuilder().setConfig(config).setInterimResults(RETRIEVE_INTERIM_RESULTS).setSingleUtterance(SINGLE_UTTERANCE_ONLY).build();
  StreamingCallable<StreamingRecognizeRequest,StreamingRecognizeResponse> callable=client.streamingRecognizeCallable();
  ApiStreamObserver<StreamingRecognizeRequest> requestObserver=callable.bidiStreamingCall(responseObserver);
  requestObserver.onNext(StreamingRecognizeRequest.newBuilder().setStreamingConfig(streamingRecognitionConfig).build());
  terminatingSessionThread=new TerminatingSessionThread(this,STREAMING_SESSION_TIMEOUT_MS);
  terminatingSessionThread.start();
  return requestObserver;
}

Fixed version (ground truth):
/** 
 * Create a new ApiStreamObserver by instantiating it and sending the first request, which contains the configuration
 * @param config the configuration of the session
 * @return the ApiStreamObserver
 */
private ApiStreamObserver<StreamingRecognizeRequest> createObserver(RecognitionConfig config){
  ResponseApiStreamingObserver<StreamingRecognizeResponse> responseObserver=new ResponseApiStreamingObserver<StreamingRecognizeResponse>(this,config.getLanguageCode());
  StreamingRecognitionConfig streamingRecognitionConfig=StreamingRecognitionConfig.newBuilder().setConfig(config).setInterimResults(RETRIEVE_INTERIM_RESULTS).setSingleUtterance(SINGLE_UTTERANCE_ONLY).build();
  StreamingCallable<StreamingRecognizeRequest,StreamingRecognizeResponse> callable=client.streamingRecognizeCallable();
  ApiStreamObserver<StreamingRecognizeRequest> requestObserver=callable.bidiStreamingCall(responseObserver);
  requestObserver.onNext(StreamingRecognizeRequest.newBuilder().setStreamingConfig(streamingRecognitionConfig).build());
  terminatingSessionThread=new TerminatingSessionThread(this,STREAMING_SESSION_TIMEOUT_MS);
  terminatingSessionThread.start();
  return requestObserver;
}
Program: 10973
Project: 10973
Buggy source:
/** 
 * The transcriber can be used as a   {@link ReceiveStreamBufferListener}to listen for new audio packets coming in through a MediaDevice. It will try to filter them based on the SSRC of the packet. If the SSRC does not match a participant added to the transcribed, an exception will be thrown <p> Note that this code is run in a Thread doing audio mixing and only has 20 ms for each frame
 * @param receiveStream the stream from which the audio was received
 * @param buffer the containing the audio as well as meta-data
 */
@Override public void bufferReceived(ReceiveStream receiveStream,Buffer buffer){
  if (!isTranscribing()) {
    return;
  }
  long ssrc=receiveStream.getSSRC() & 0xffffffffL;
  Participant p=participants.get(ssrc);
  if (p != null) {
    p.giveBuffer(buffer);
  }
 else {
    logger.warn("String_Node_Str" + ssrc + "String_Node_Str"+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * The transcriber can be used as a   {@link ReceiveStreamBufferListener}to listen for new audio packets coming in through a MediaDevice. It will try to filter them based on the SSRC of the packet. If the SSRC does not match a participant added to the transcribed, an exception will be thrown <p> Note that this code is run in a Thread doing audio mixing and only has 20 ms for each frame
 * @param receiveStream the stream from which the audio was received
 * @param buffer the containing the audio as well as meta-data
 */
@Override public void bufferReceived(ReceiveStream receiveStream,Buffer buffer){
  if (!isTranscribing()) {
    logger.trace("String_Node_Str");
    return;
  }
  long ssrc=receiveStream.getSSRC() & 0xffffffffL;
  Participant p=participants.get(ssrc);
  if (p != null) {
    logger.trace("String_Node_Str");
    p.giveBuffer(buffer);
  }
 else {
    logger.warn("String_Node_Str" + ssrc + "String_Node_Str"+ "String_Node_Str");
  }
}
Program: 10974
Project: 10974
Buggy source:
@Override protected String formatSpeechEvent(Transcript.SpeechEvent e){
  String name=e.getName();
  String timeStamp=e.getTimeString();
  String transcription=e.getResult().getTranscription();
  String base=String.format(UNFORMATTED_EVENT_BASE,timeStamp,name);
  String speech=String.format(UNFORMATTED_SPEECH,transcription);
  String formatted=base + String.format(UNFORMATTED_SPEECH,transcription);
  return formatToMaximumLineLength(formatted,MAX_LINE_WIDTH,base.length() + (speech.length() - transcription.length())) + NEW_LINE;
}

Fixed version (ground truth):
@Override protected String formatSpeechEvent(Transcript.SpeechEvent e){
  String name=e.getName();
  String timeStamp=e.getTimeString();
  String transcription=e.getResult().getAlternatives().iterator().next().getTranscription();
  String base=String.format(UNFORMATTED_EVENT_BASE,timeStamp,name);
  String speech=String.format(UNFORMATTED_SPEECH,transcription);
  String formatted=base + String.format(UNFORMATTED_SPEECH,transcription);
  return formatToMaximumLineLength(formatted,MAX_LINE_WIDTH,base.length() + (speech.length() - transcription.length())) + NEW_LINE;
}