nus-yam/ex-repair huggingface dataset:
Program: 63158
Project: 63158
Buggy source:
/** 
 * @param ontid
 * @return
 * @throws SDKException
 * @throws ConnectorException
 * @throws IOException
 */
public String sendGetDDO(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ResultIsNull);
  }
  Map map=parseDdoData2(ontid,res);
  if (map.size() == 0) {
    return "String_Node_Str";
  }
  return JSON.toJSONString(map);
}

Fixed version (ground truth):
/** 
 * @param ontid
 * @return
 * @throws SDKException
 * @throws ConnectorException
 * @throws IOException
 */
public String sendGetDDO(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    return res;
  }
  Map map=parseDdoData2(ontid,res);
  if (map.size() == 0) {
    return "String_Node_Str";
  }
  return JSON.toJSONString(map);
}
Program: 63159
Project: 63159
Buggy source:
/** 
 * @param ontid
 * @return
 * @throws SDKException
 * @throws ConnectorException
 * @throws IOException
 */
public String sendGetKeyState(String ontid,int index) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes(),index);
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    throw new SDKException(ErrorCode.ResultIsNull);
  }
  return new String(Helper.hexToBytes(res));
}

Fixed version (ground truth):
/** 
 * @param ontid
 * @return
 * @throws SDKException
 * @throws ConnectorException
 * @throws IOException
 */
public String sendGetKeyState(String ontid,int index) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes(),index);
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0,0);
  Object obj=sdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  String res=((JSONObject)obj).getString("String_Node_Str");
  if (res.equals("String_Node_Str")) {
    return res;
  }
  return new String(Helper.hexToBytes(res));
}
Program: 63162
Project: 63162
Buggy source:
@Test public void sendRawTransactionPreExec() throws Exception {
  byte[] parabytes=ontSdk.nativevm().ontId().buildParams(Address.decodeBase58(address).toArray());
  Transaction tx=ontSdk.vm().makeInvokeCodeTransaction(ontContract,"String_Node_Str",parabytes,VmType.Native.value(),null,0);
  Object obj=ontSdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  Assert.assertNotEquals(null,obj);
}

Fixed version (ground truth):
@Test public void sendRawTransactionPreExec() throws Exception {
  byte[] parabytes=ontSdk.nativevm().ontId().buildParams(Address.decodeBase58(address).toArray());
  Transaction tx=ontSdk.vm().makeInvokeCodeTransaction(ontContract,"String_Node_Str",parabytes,VmType.Native.value(),null,ontSdk.DEFAULT_GAS_LIMIT,0);
  Object obj=ontSdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
  Assert.assertNotEquals(null,obj);
}
Program: 63163
Project: 63163
Buggy source:
@Before public void setUp() throws Exception {
  ontSdk=OntSdk.getInstance();
  String restUrl="String_Node_Str";
  ontSdk.setRestful(restUrl);
  ontSdk.setDefaultConnect(ontSdk.getRestful());
  ontSdk.openWalletFile(wallet);
  if (ontSdk.getWalletMgr().getIdentitys().size() < 1) {
    identity=ontSdk.getWalletMgr().createIdentity(password);
  }
 else {
    identity=ontSdk.getWalletMgr().getIdentitys().get(0);
  }
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  ontSdk=OntSdk.getInstance();
  String restUrl=OntSdkTest.URL;
  ontSdk.setRestful(restUrl);
  ontSdk.setDefaultConnect(ontSdk.getRestful());
  ontSdk.openWalletFile(wallet);
  if (ontSdk.getWalletMgr().getIdentitys().size() < 1) {
    identity=ontSdk.getWalletMgr().createIdentity(password);
  }
 else {
    identity=ontSdk.getWalletMgr().getIdentitys().get(0);
  }
}
Program: 63164
Project: 63164
Buggy source:
/** 
 * @param tx
 * @param addr
 * @param password
 * @return
 * @throws Exception
 */
public Transaction addSign(Transaction tx,String addr,String password) throws Exception {
  if (tx.sigs == null) {
    tx.sigs=new Sig[0];
  }
  Sig[] sigs=new Sig[tx.sigs.length + 1];
  for (int i=0; i < tx.sigs.length; i++) {
    sigs[i]=tx.sigs[i];
  }
  sigs[tx.sigs.length]=new Sig();
  sigs[tx.sigs.length].M=1;
  sigs[tx.sigs.length].pubKeys=new byte[1][];
  sigs[tx.sigs.length].sigData=new byte[1][];
  sigs[tx.sigs.length].pubKeys[0]=Helper.hexToBytes(getWalletMgr().getAccountInfo(addr,password).pubkey);
  sigs[tx.sigs.length].sigData[0]=tx.sign(getWalletMgr().getAccount(addr,password),signatureScheme);
  tx.sigs=sigs;
  return tx;
}

Fixed version (ground truth):
public Transaction addSign(Transaction tx,Account acct) throws Exception {
  if (tx.sigs == null) {
    tx.sigs=new Sig[0];
  }
  Sig[] sigs=new Sig[tx.sigs.length + 1];
  for (int i=0; i < tx.sigs.length; i++) {
    sigs[i]=tx.sigs[i];
  }
  sigs[tx.sigs.length]=new Sig();
  sigs[tx.sigs.length].M=1;
  sigs[tx.sigs.length].pubKeys=new byte[1][];
  sigs[tx.sigs.length].sigData=new byte[1][];
  sigs[tx.sigs.length].pubKeys[0]=acct.serializePublicKey();
  sigs[tx.sigs.length].sigData[0]=tx.sign(acct,signatureScheme);
  tx.sigs=sigs;
  return tx;
}
Program: 63165
Project: 63165
Buggy source:
public static Address addressFromPubKey(byte[] publicKey){
  byte[] bys=Digest.hash160(publicKey);
  bys[0]=0x01;
  Address u160=new Address(bys);
  return u160;
}

Fixed version (ground truth):
public static Address addressFromPubKey(byte[] publicKey){
  byte[] bys=Digest.hash160(publicKey);
  bys[0]=0x01;
  return new Address(bys);
}
Program: 63166
Project: 63166
Buggy source:
public String toBase58(){
  byte[] data=new byte[25];
  data[0]=COIN_VERSION;
  System.arraycopy(toArray(),0,data,1,20);
  byte[] checksum=Digest.sha256(Digest.sha256(data,0,21));
  System.arraycopy(checksum,0,data,21,4);
  return Base58.encode(data);
}

Fixed version (ground truth):
public String toBase58(){
  byte[] data=new byte[25];
  data[0]=COIN_VERSION_ONT;
  System.arraycopy(toArray(),0,data,1,20);
  byte[] checksum=Digest.sha256(Digest.sha256(data,0,21));
  System.arraycopy(checksum,0,data,21,4);
  return Base58.encode(data);
}
Program: 63167
Project: 63167
Buggy source:
public static Address decodeBase58(String address) throws SDKException {
  byte[] data=Base58.decode(address);
  if (data.length != 25) {
    throw new SDKException(ErrorCode.ParamError + "String_Node_Str");
  }
  if (data[0] != COIN_VERSION) {
    throw new SDKException(ErrorCode.ParamError);
  }
  byte[] checksum=Digest.sha256(Digest.sha256(data,0,21));
  for (int i=0; i < 4; i++) {
    if (data[data.length - 4 + i] != checksum[i]) {
      throw new IllegalArgumentException();
    }
  }
  byte[] buffer=new byte[20];
  System.arraycopy(data,1,buffer,0,20);
  return new Address(buffer);
}

Fixed version (ground truth):
public static Address decodeBase58(String address) throws SDKException {
  byte[] data=Base58.decode(address);
  if (data.length != 25) {
    throw new SDKException(ErrorCode.ParamError + "String_Node_Str");
  }
  if (data[0] != COIN_VERSION_ONT) {
    throw new SDKException(ErrorCode.ParamError);
  }
  byte[] checksum=Digest.sha256(Digest.sha256(data,0,21));
  for (int i=0; i < 4; i++) {
    if (data[data.length - 4 + i] != checksum[i]) {
      throw new IllegalArgumentException();
    }
  }
  byte[] buffer=new byte[20];
  System.arraycopy(data,1,buffer,0,20);
  return new Address(buffer);
}
Program: 63168
Project: 63168
Buggy source:
public static void main(String[] args){
  try {
    OntSdk sdk=getOntSdk();
    Account info1=null;
    Account info2=null;
    Account info3=null;
    sdk.setSignatureScheme(SignatureScheme.SHA256WITHECDSA);
    if (sdk.getWalletMgr().getAccounts().size() < 3) {
      String privatekey0="String_Node_Str";
      info1=sdk.getWalletMgr().createAccountFromPriKey("String_Node_Str",privatekey0);
      info2=sdk.getWalletMgr().createAccount("String_Node_Str");
      info3=sdk.getWalletMgr().createAccountFromPriKey("String_Node_Str","String_Node_Str");
      info3.label="String_Node_Str";
      sdk.getWalletMgr().writeWallet();
    }
    info1=sdk.getWalletMgr().getAccounts().get(0);
    info2=sdk.getWalletMgr().getAccounts().get(1);
    info3=sdk.getWalletMgr().getAccounts().get(2);
    System.out.println(info1.address);
    System.out.println(info2.address);
    System.out.println(info3.address);
    System.out.println(sdk.getConnect().getBalance(info3.address));
    System.out.println("String_Node_Str");
    String hash=sdk.nativevm().ong().claimOng(info1.address,"String_Node_Str",info3.address,2960000000000L,info1.address,"String_Node_Str",sdk.DEFAULT_GAS_LIMIT,0);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    OntSdk sdk=getOntSdk();
    Account info1=null;
    Account info2=null;
    Account info3=null;
    sdk.setSignatureScheme(SignatureScheme.SHA256WITHECDSA);
    if (sdk.getWalletMgr().getAccounts().size() < 3) {
      String privatekey0="String_Node_Str";
      info1=sdk.getWalletMgr().createAccountFromPriKey("String_Node_Str",privatekey0);
      info2=sdk.getWalletMgr().createAccount("String_Node_Str");
      info3=sdk.getWalletMgr().createAccountFromPriKey("String_Node_Str","String_Node_Str");
      info3.label="String_Node_Str";
      sdk.getWalletMgr().writeWallet();
    }
    info1=sdk.getWalletMgr().getAccounts().get(0);
    info2=sdk.getWalletMgr().getAccounts().get(1);
    info3=sdk.getWalletMgr().getAccounts().get(2);
    System.out.println(info1.address);
    System.out.println(info2.address);
    System.out.println(info3.address);
    System.out.println(sdk.getConnect().getBalance(info3.address));
    System.out.println("String_Node_Str");
    System.out.println(sdk.nativevm().ong().unclaimOng(info1.address));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 63170
Project: 63170
Buggy source:
@Before public void setUp() throws SDKException {
  String ip="String_Node_Str";
  String restUrl=ip + "String_Node_Str" + "String_Node_Str";
  ontSdk=OntSdk.getInstance();
  ontSdk.setRestful(restUrl);
  ontSdk.setDefaultConnect(ontSdk.getRestful());
  ontSdk.openWalletFile(walletFile);
}

Fixed version (ground truth):
@Before public void setUp() throws SDKException {
  String restUrl=OntSdkTest.URL;
  ontSdk=OntSdk.getInstance();
  ontSdk.setRestful(restUrl);
  ontSdk.setDefaultConnect(ontSdk.getRestful());
  ontSdk.openWalletFile(walletFile);
}
Program: 63171
Project: 63171
Buggy source:
/** 
 * @param codeStr
 * @param needStorage
 * @param name
 * @param codeVersion
 * @param author
 * @param email
 * @param desp
 * @param vmtype
 * @param payer
 * @param gaslimit
 * @param gasprice
 * @return
 * @throws SDKException
 */
public DeployCode makeDeployCodeTransaction(String codeStr,boolean needStorage,String name,String codeVersion,String author,String email,String desp,byte vmtype,String payer,long gaslimit,long gasprice) throws SDKException {
  DeployCode tx=new DeployCode();
  if (payer != null) {
    tx.payer=Address.decodeBase58(payer.replace(Common.didont,"String_Node_Str"));
  }
  tx.attributes=new Attribute[1];
  tx.attributes[0]=new Attribute();
  tx.attributes[0].usage=AttributeUsage.Nonce;
  tx.attributes[0].data=UUID.randomUUID().toString().getBytes();
  tx.code=Helper.hexToBytes(codeStr);
  tx.version=codeVersion;
  tx.vmType=vmtype;
  tx.needStorage=needStorage;
  tx.name=name;
  tx.author=author;
  tx.email=email;
  tx.gasLimit=gaslimit;
  tx.gasLimit=gasprice;
  tx.description=desp;
  return tx;
}

Fixed version (ground truth):
/** 
 * @param codeStr
 * @param needStorage
 * @param name
 * @param codeVersion
 * @param author
 * @param email
 * @param desp
 * @param vmtype
 * @param payer
 * @param gaslimit
 * @param gasprice
 * @return
 * @throws SDKException
 */
public DeployCode makeDeployCodeTransaction(String codeStr,boolean needStorage,String name,String codeVersion,String author,String email,String desp,byte vmtype,String payer,long gaslimit,long gasprice) throws SDKException {
  DeployCode tx=new DeployCode();
  if (payer != null) {
    tx.payer=Address.decodeBase58(payer.replace(Common.didont,"String_Node_Str"));
  }
  tx.attributes=new Attribute[1];
  tx.attributes[0]=new Attribute();
  tx.attributes[0].usage=AttributeUsage.Nonce;
  tx.attributes[0].data=UUID.randomUUID().toString().getBytes();
  tx.code=Helper.hexToBytes(codeStr);
  tx.version=codeVersion;
  tx.vmType=vmtype;
  tx.needStorage=needStorage;
  tx.name=name;
  tx.author=author;
  tx.email=email;
  tx.gasLimit=gaslimit;
  tx.gasPrice=gasprice;
  tx.description=desp;
  return tx;
}
Program: 63172
Project: 63172
Buggy source:
public String sendGetAttributes(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0);
  Object obj=sdk.getConnectMgr().sendRawTransactionPreExec(tx.toHexString());
  if (obj == null || ((String)obj).length() == 0) {
    throw new SDKException(ErrorCode.ResultIsNull);
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(Helper.hexToBytes((String)obj));
  BinaryReader br=new BinaryReader(bais);
  Map attributeMap=new HashMap();
  while (true) {
    try {
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
    }
 catch (    Exception e) {
      break;
    }
  }
  return JSON.toJSONString(attributeMap);
}

Fixed version (ground truth):
public String sendGetAttributes(String ontid) throws SDKException, ConnectorException, IOException {
  if (contractAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  byte[] parabytes=buildParams(ontid.getBytes());
  Transaction tx=sdk.vm().makeInvokeCodeTransaction(contractAddress,"String_Node_Str",parabytes,VmType.Native.value(),null,0);
  Object obj=sdk.getConnectMgr().sendRawTransactionPreExec(tx.toHexString());
  if (obj == null || ((String)obj).length() == 0) {
    throw new SDKException(ErrorCode.ResultIsNull);
  }
  ByteArrayInputStream bais=new ByteArrayInputStream(Helper.hexToBytes((String)obj));
  BinaryReader br=new BinaryReader(bais);
  List attrsList=new ArrayList();
  while (true) {
    try {
      Map attributeMap=new HashMap();
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attributeMap.put("String_Node_Str",new String(br.readVarBytes()));
      attrsList.add(attributeMap);
    }
 catch (    Exception e) {
      break;
    }
  }
  return JSON.toJSONString(attrsList);
}
Program: 63173
Project: 63173
Buggy source:
@Override public void deserialize(BinaryReader reader) throws IOException {
  deserializeUnsigned(reader);
  int len=(int)reader.readVarInt();
  sigData=new String[len];
  for (int i=0; i < len; i++) {
    this.sigData[i]=Helper.toHexString(reader.readVarBytes());
  }
  len=reader.readInt();
  transactions=new Transaction[len];
  for (int i=0; i < transactions.length; i++) {
    transactions[i]=Transaction.deserializeFrom(reader);
  }
  if (transactions.length > 0) {
    if (transactions[0].txType != TransactionType.Bookkeeping || Arrays.stream(transactions).skip(1).anyMatch(p -> p.txType == TransactionType.Bookkeeping)) {
      throw new IOException();
    }
  }
}

Fixed version (ground truth):
@Override public void deserialize(BinaryReader reader) throws IOException {
  deserializeUnsigned(reader);
  int len=(int)reader.readVarInt();
  sigData=new String[len];
  for (int i=0; i < len; i++) {
    this.sigData[i]=Helper.toHexString(reader.readVarBytes());
  }
  len=reader.readInt();
  transactions=new Transaction[len];
  for (int i=0; i < transactions.length; i++) {
    transactions[i]=Transaction.deserializeFrom(reader);
  }
  if (transactions.length > 0) {
    if ((height != 0 && transactions[0].txType != TransactionType.Bookkeeping) || Arrays.stream(transactions).skip(1).anyMatch(p -> p.txType == TransactionType.Bookkeeping)) {
      throw new IOException();
    }
  }
}
Program: 63174
Project: 63174
Buggy source:
public Account(String alg,Object[] params,String encAlg,String scheme,String hash){
  this.algorithm=alg;
  this.parameters.put("String_Node_Str",params[0]);
  this.signatureScheme=scheme;
  this.encAlg=encAlg;
  this.hash=hash;
  this.algorithm=algorithm;
  this.extra=null;
}

Fixed version (ground truth):
public Account(String alg,Object[] params,String encAlg,String scheme,String hash){
  this.algorithm=alg;
  this.parameters.put("String_Node_Str",params[0]);
  this.signatureScheme=scheme;
  this.encAlg=encAlg;
  this.hash=hash;
  this.extra=null;
}
Program: 63175
Project: 63175
Buggy source:
@Override public void serializeUnsigned(BinaryWriter writer) throws IOException {
  writer.writeInt(version);
  writer.writeSerializable(prevBlockHash);
  writer.writeSerializable(transactionsRoot);
  writer.writeSerializable(blockRoot);
  writer.writeInt(timestamp);
  writer.writeInt(height);
  writer.writeLong(consensusData);
  writer.writeSerializable(nextBookkeeper);
}

Fixed version (ground truth):
@Override public void serializeUnsigned(BinaryWriter writer) throws IOException {
  writer.writeInt(version);
  writer.writeSerializable(prevBlockHash);
  writer.writeSerializable(transactionsRoot);
  writer.writeSerializable(blockRoot);
  writer.writeInt(timestamp);
  writer.writeInt(height);
  writer.writeLong(consensusData);
  writer.writeVarBytes(consensusPayload);
  writer.writeSerializable(nextBookkeeper);
}
Program: 63176
Project: 63176
Buggy source:
public String sendRevoke(String ontid,String password,String claimId) throws Exception {
  if (codeAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  if (claimId == null || claimId == "String_Node_Str") {
    throw new SDKException(ErrorCode.NullKeyOrValue);
  }
  String addr=ontid.replace(Common.didont,"String_Node_Str");
  byte[] did=(Common.didont + addr).getBytes();
  AccountInfo info=sdk.getWalletMgr().getAccountInfo(addr,password,sdk.keyType,sdk.curveParaSpec);
  List list=new ArrayList<Object>();
  list.add("String_Node_Str".getBytes());
  List tmp=new ArrayList<Object>();
  tmp.add(Helper.hexToBytes(claimId));
  tmp.add(did);
  list.add(tmp);
  Transaction tx=makeInvokeTransaction(list,info);
  sdk.signTx(tx,addr,password);
  boolean b=sdk.getConnectMgr().sendRawTransaction(tx.toHexString());
  if (b) {
    return tx.hash().toString();
  }
  return null;
}

Fixed version (ground truth):
public String sendRevoke(String ontid,String password,String claimId) throws Exception {
  if (codeAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  if (claimId == null || claimId == "String_Node_Str") {
    throw new SDKException(ErrorCode.NullKeyOrValue);
  }
  String addr=ontid.replace(Common.didont,"String_Node_Str");
  byte[] did=(Common.didont + addr).getBytes();
  AccountInfo info=sdk.getWalletMgr().getAccountInfo(addr,password);
  List list=new ArrayList<Object>();
  list.add("String_Node_Str".getBytes());
  List tmp=new ArrayList<Object>();
  tmp.add(Helper.hexToBytes(claimId));
  tmp.add(did);
  list.add(tmp);
  Transaction tx=makeInvokeTransaction(list,info);
  sdk.signTx(tx,addr,password);
  boolean b=sdk.getConnectMgr().sendRawTransaction(tx.toHexString());
  if (b) {
    return tx.hash().toString();
  }
  return null;
}
Program: 63177
Project: 63177
Buggy source:
public String sendCommit(String ontid,String password,String claimId) throws Exception {
  if (codeAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  if (claimId == null || claimId == "String_Node_Str") {
    throw new SDKException(ErrorCode.NullKeyOrValue);
  }
  String addr=ontid.replace(Common.didont,"String_Node_Str");
  byte[] did=(Common.didont + addr).getBytes();
  AccountInfo info=sdk.getWalletMgr().getAccountInfo(addr,password,sdk.keyType,sdk.curveParaSpec);
  List list=new ArrayList<Object>();
  list.add("String_Node_Str".getBytes());
  List tmp=new ArrayList<Object>();
  tmp.add(Helper.hexToBytes(claimId));
  tmp.add(did);
  list.add(tmp);
  Transaction tx=makeInvokeTransaction(list,info);
  sdk.signTx(tx,addr,password);
  boolean b=sdk.getConnectMgr().sendRawTransaction(tx.toHexString());
  if (b) {
    return tx.hash().toString();
  }
  return null;
}

Fixed version (ground truth):
public String sendCommit(String ontid,String password,String claimId) throws Exception {
  if (codeAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  if (claimId == null || claimId == "String_Node_Str") {
    throw new SDKException(ErrorCode.NullKeyOrValue);
  }
  String addr=ontid.replace(Common.didont,"String_Node_Str");
  byte[] did=(Common.didont + addr).getBytes();
  AccountInfo info=sdk.getWalletMgr().getAccountInfo(addr,password);
  List list=new ArrayList<Object>();
  list.add("String_Node_Str".getBytes());
  List tmp=new ArrayList<Object>();
  tmp.add(Helper.hexToBytes(claimId));
  tmp.add(did);
  list.add(tmp);
  Transaction tx=makeInvokeTransaction(list,info);
  sdk.signTx(tx,addr,password);
  boolean b=sdk.getConnectMgr().sendRawTransaction(tx.toHexString());
  if (b) {
    return tx.hash().toString();
  }
  return null;
}
Program: 63178
Project: 63178
Buggy source:
public String sendGetStatus(String ontid,String password,String claimId) throws Exception {
  if (codeAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  if (claimId == null || claimId == "String_Node_Str") {
    throw new SDKException(ErrorCode.NullKeyOrValue);
  }
  String addr=ontid.replace(Common.didont,"String_Node_Str");
  AccountInfo info=sdk.getWalletMgr().getAccountInfo(addr,password,sdk.keyType,sdk.curveParaSpec);
  List list=new ArrayList<Object>();
  list.add("String_Node_Str".getBytes());
  List tmp=new ArrayList<Object>();
  tmp.add(Helper.hexToBytes(claimId));
  list.add(tmp);
  Transaction tx=makeInvokeTransaction(list,info);
  sdk.signTx(tx,addr,password);
  Object obj=sdk.getConnectMgr().sendRawTransactionPreExec(tx.toHexString());
  if (obj != null) {
    return (String)obj;
  }
  return null;
}

Fixed version (ground truth):
public String sendGetStatus(String ontid,String password,String claimId) throws Exception {
  if (codeAddress == null) {
    throw new SDKException(ErrorCode.NullCodeHash);
  }
  if (claimId == null || claimId == "String_Node_Str") {
    throw new SDKException(ErrorCode.NullKeyOrValue);
  }
  String addr=ontid.replace(Common.didont,"String_Node_Str");
  AccountInfo info=sdk.getWalletMgr().getAccountInfo(addr,password);
  List list=new ArrayList<Object>();
  list.add("String_Node_Str".getBytes());
  List tmp=new ArrayList<Object>();
  tmp.add(Helper.hexToBytes(claimId));
  list.add(tmp);
  Transaction tx=makeInvokeTransaction(list,info);
  sdk.signTx(tx,addr,password);
  Object obj=sdk.getConnectMgr().sendRawTransactionPreExec(tx.toHexString());
  if (obj != null) {
    return (String)obj;
  }
  return null;
}
Program: 63180
Project: 63180
Buggy source:
public byte[] generateSignature(byte[] msg,SignatureScheme scheme,Object param) throws Exception {
  if (msg == null || msg.length == 0) {
    throw new Exception(ErrorCode.InvalidMessage);
  }
  if (this.privateKey == null) {
    throw new Exception("String_Node_Str");
  }
  SignatureHandler ctx=new SignatureHandler(keyType,scheme);
  AlgorithmParameterSpec paramSpec=null;
  if (scheme == SignatureScheme.SM3WITHSM2 && param != null) {
    if (param instanceof String) {
      paramSpec=new SM2ParameterSpec(Strings.toByteArray((String)param));
    }
 else {
      throw new Exception("String_Node_Str");
    }
  }
  byte[] signature=new Signature(scheme,paramSpec,ctx.generateSignature(privateKey,msg,paramSpec)).toBytes();
  return signature;
}

Fixed version (ground truth):
public byte[] generateSignature(byte[] msg,SignatureScheme scheme,Object param) throws Exception {
  if (msg == null || msg.length == 0) {
    throw new Exception(ErrorCode.InvalidMessage);
  }
  if (this.privateKey == null) {
    throw new Exception("String_Node_Str");
  }
  SignatureHandler ctx=new SignatureHandler(keyType,scheme);
  AlgorithmParameterSpec paramSpec=null;
  if (scheme == SignatureScheme.SM3WITHSM2) {
    if (param instanceof String) {
      paramSpec=new SM2ParameterSpec(Strings.toByteArray((String)param));
    }
 else     if (param == null) {
      paramSpec=new SM2ParameterSpec("String_Node_Str".getBytes());
    }
 else {
      throw new Exception("String_Node_Str");
    }
  }
  byte[] signature=new Signature(scheme,paramSpec,ctx.generateSignature(privateKey,msg,paramSpec)).toBytes();
  return signature;
}
Program: 63181
Project: 63181
Buggy source:
public Signature(byte[] data) throws Exception {
  if (data == null) {
    throw new Exception("String_Node_Str");
  }
  if (data.length < 2) {
    throw new Exception(ErrorCode.InvalidSignatureDataLen);
  }
  this.scheme=SignatureScheme.values()[data[0]];
  if (scheme == SignatureScheme.SM3WITHSM2) {
    int i=0;
    while (i < data.length && data[i] != 0) {
      i++;
    }
    if (i >= data.length) {
      throw new Exception(ErrorCode.InvalidSignatureData);
    }
    this.param=new SM2ParameterSpec(Arrays.copyOfRange(data,1,i));
  }
  this.value=Arrays.copyOfRange(data,1,data.length);
}

Fixed version (ground truth):
public Signature(byte[] data) throws Exception {
  if (data == null) {
    throw new Exception("String_Node_Str");
  }
  if (data.length < 2) {
    throw new Exception(ErrorCode.InvalidSignatureDataLen);
  }
  this.scheme=SignatureScheme.values()[data[0]];
  if (scheme == SignatureScheme.SM3WITHSM2) {
    int i=0;
    while (i < data.length && data[i] != 0) {
      i++;
    }
    if (i >= data.length) {
      throw new Exception(ErrorCode.InvalidSignatureData);
    }
    this.param=new SM2ParameterSpec(Arrays.copyOfRange(data,1,i));
    this.value=Arrays.copyOfRange(data,i + 1,data.length);
  }
 else {
    this.value=Arrays.copyOfRange(data,1,data.length);
  }
}
Program: 63182
Project: 63182
Buggy source:
public boolean setValue(Object value){
  try {
    if (value == null) {
      this.value=null;
    }
 else     if ("String_Node_Str".equals(type)) {
      byte[] tmp=(byte[])value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      this.value=(String)value;
    }
 else     if ("String_Node_Str".equals(type)) {
      boolean tmp=(boolean)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      int tmp=(int)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      Array tmp=(Array)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      Object tmp=(Object)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
    }
 else {
      throw new SDKException("String_Node_Str");
    }
    return true;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return false;
}

Fixed version (ground truth):
public boolean setValue(Object value){
  try {
    if (value == null) {
      this.value=null;
    }
 else     if ("String_Node_Str".equals(type)) {
      byte[] tmp=(byte[])value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      this.value=(String)value;
    }
 else     if ("String_Node_Str".equals(type)) {
      boolean tmp=(boolean)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      int tmp=(int)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      List tmp=(List)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
      Object tmp=(Object)value;
      this.value=JSON.toJSONString(tmp);
    }
 else     if ("String_Node_Str".equals(type)) {
    }
 else {
      throw new SDKException("String_Node_Str");
    }
    return true;
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return false;
}
Program: 63183
Project: 63183
Buggy source:
@Test public void getBlock() throws ConnectorException, IOException {
  Block b=ontSdk.getConnectMgr().getBlock(20);
  Assert.assertNotNull(b);
}

Fixed version (ground truth):
@Test public void getBlock() throws ConnectorException, IOException {
  int blockHeight=ontSdk.getConnectMgr().getBlockHeight();
  Block b=ontSdk.getConnectMgr().getBlock(blockHeight);
  Assert.assertNotNull(b);
}
Program: 63184
Project: 63184
Buggy source:
@Test public void getBlockByBlockhash() throws ConnectorException, IOException {
  Block b2=ontSdk.getConnectMgr().getBlock(20);
  blockHash=b2.hash().toString();
  Block b=ontSdk.getConnectMgr().getBlock(blockHash);
  Assert.assertNotNull(b);
}

Fixed version (ground truth):
@Test public void getBlockByBlockhash() throws ConnectorException, IOException {
  int blockHeight=ontSdk.getConnectMgr().getBlockHeight();
  Block b2=ontSdk.getConnectMgr().getBlock(blockHeight);
  blockHash=b2.hash().toString();
  Block b=ontSdk.getConnectMgr().getBlock(blockHash);
  Assert.assertNotNull(b);
}
Program: 63185
Project: 63185
Buggy source:
@Test public void getBlockJson() throws ConnectorException, IOException {
  Object obj=ontSdk.getConnectMgr().getBlockJson(20);
  Assert.assertNotNull(obj);
}

Fixed version (ground truth):
@Test public void getBlockJson() throws ConnectorException, IOException {
  int blockHeight=ontSdk.getConnectMgr().getBlockHeight();
  Object obj=ontSdk.getConnectMgr().getBlockJson(blockHeight);
  Assert.assertNotNull(obj);
}
Program: 63186
Project: 63186
Buggy source:
@Test public void getBlockJsonbyHash() throws ConnectorException, IOException {
  Block b2=ontSdk.getConnectMgr().getBlock(20);
  blockHash=b2.hash().toString();
  Object obj=ontSdk.getConnectMgr().getBlockJson(blockHash);
  Assert.assertNotNull(obj);
}

Fixed version (ground truth):
@Test public void getBlockJsonbyHash() throws ConnectorException, IOException {
  int blockHeight=ontSdk.getConnectMgr().getBlockHeight();
  Block b2=ontSdk.getConnectMgr().getBlock(blockHeight);
  blockHash=b2.hash().toString();
  Object obj=ontSdk.getConnectMgr().getBlockJson(blockHash);
  Assert.assertNotNull(obj);
}
Program: 63187
Project: 63187
Buggy source:
@Before public void setUp() throws Exception {
  ontSdk=OntSdk.getInstance();
  String restUrl="String_Node_Str";
  codeHex="String_Node_Str";
  codeAddress="String_Node_Str";
  ontSdk.setRestful(restUrl);
  ontSdk.setDefaultConnect(ontSdk.getRestful());
  ontSdk.openWalletFile("String_Node_Str");
  ontSdk.setCodeAddress(codeAddress);
  String funStr="String_Node_Str";
  abiFunction=JSON.parseObject(funStr,AbiFunction.class);
  if (ontSdk.getWalletMgr().getIdentitys().size() < 1) {
    Identity did=ontSdk.getOntIdTx().sendRegister("String_Node_Str");
    Thread.sleep(6000);
  }
  did=ontSdk.getWalletMgr().getIdentitys().get(0);
  AccountInfo info=ontSdk.getWalletMgr().getAccountInfo(did.ontid,"String_Node_Str");
  abiFunction.setParamsValue(did.ontid.getBytes(),"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),Helper.hexToBytes(info.pubkey));
  String funcStr2="String_Node_Str";
  abiFunction2=JSON.parseObject(funcStr2,AbiFunction.class);
  abiFunction2.setParamsValue(did.ontid.getBytes(),UUID.randomUUID().toString().getBytes());
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  ontSdk=OntSdk.getInstance();
  String restUrl="String_Node_Str";
  codeHex="String_Node_Str";
  codeAddress="String_Node_Str";
  ontSdk.setRestful(restUrl);
  ontSdk.setDefaultConnect(ontSdk.getRestful());
  ontSdk.openWalletFile("String_Node_Str");
  ontSdk.setCodeAddress(codeAddress);
  String funStr="String_Node_Str";
  abiFunction=JSON.parseObject(funStr,AbiFunction.class);
  if (ontSdk.getWalletMgr().getIdentitys().size() < 1) {
    Identity did=ontSdk.getOntIdTx().sendRegister("String_Node_Str");
    Thread.sleep(6000);
  }
  did=ontSdk.getWalletMgr().getIdentitys().get(0);
  AccountInfo info=ontSdk.getWalletMgr().getAccountInfo(did.ontid,"String_Node_Str");
  abiFunction.setParamsValue(did.ontid.getBytes(),"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),"String_Node_Str".getBytes(),Helper.hexToBytes(info.pubkey));
  String funcStr2="String_Node_Str";
  abiFunction2=JSON.parseObject(funcStr2,AbiFunction.class);
  abiFunction2.setParamsValue(did.ontid.getBytes(),UUID.randomUUID().toString().getBytes());
  Transaction tx=ontSdk.getSmartcodeTx().makeDeployCodeTransaction(codeHex,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",VmType.NEOVM.value());
  String txHex=Helper.toHexString(tx.toArray());
  boolean b=ontSdk.getConnectMgr().sendRawTransaction(txHex);
  Thread.sleep(6000);
}
Program: 63188
Project: 63188
Buggy source:
public static List getProof(UInt256 leaf_hash,int node_index,UInt256[] audit_path,int tree_size){
  List nodes=new ArrayList<>();
  int last_node=tree_size - 1;
  int pos=0;
  for (; last_node > 0; ) {
    if (node_index % 2 == 1) {
      Map map=new HashMap();
      map.put("String_Node_Str","String_Node_Str");
      map.put("String_Node_Str",audit_path[pos].toHexString());
      nodes.add(map);
      pos+=1;
    }
 else     if (node_index < last_node) {
      pos+=1;
      Map map=new HashMap();
      map.put("String_Node_Str","String_Node_Str");
      map.put("String_Node_Str",audit_path[pos].toHexString());
      nodes.add(map);
    }
    node_index/=2;
    last_node/=2;
  }
  return nodes;
}

Fixed version (ground truth):
public static List getProof(UInt256 leaf_hash,int node_index,UInt256[] audit_path,int tree_size){
  List nodes=new ArrayList<>();
  int last_node=tree_size - 1;
  int pos=0;
  for (; last_node > 0; ) {
    if (node_index % 2 == 1) {
      Map map=new HashMap();
      map.put("String_Node_Str","String_Node_Str");
      map.put("String_Node_Str",audit_path[pos].toHexString());
      nodes.add(map);
      pos+=1;
    }
 else     if (node_index < last_node) {
      Map map=new HashMap();
      map.put("String_Node_Str","String_Node_Str");
      map.put("String_Node_Str",audit_path[pos].toHexString());
      nodes.add(map);
      pos+=1;
    }
    node_index/=2;
    last_node/=2;
  }
  return nodes;
}
Program: 63189
Project: 63189
Buggy source:
private long modTimeToMilis(String modTime){
  if (modTime.lastIndexOf("String_Node_Str") > 19 || modTime.lastIndexOf("String_Node_Str") > 19) {
    return modTimeZonedToMillis(modTime);
  }
  String[] dateTime=modTime.split("String_Node_Str");
  String yearMonthDay=dateTime[0];
  String hourMinuteSecond=dateTime[1].substring(0,dateTime[1].length() - 1);
  if (hourMinuteSecond.contains("String_Node_Str")) {
    int index=hourMinuteSecond.indexOf("String_Node_Str");
    hourMinuteSecond=hourMinuteSecond.substring(0,index);
  }
  String formattedDate=yearMonthDay + "String_Node_Str" + hourMinuteSecond+ "String_Node_Str";
  long dateInMillis;
  Date date;
  SimpleDateFormat simpleDateFormat=new SimpleDateFormat("String_Node_Str");
  try {
    date=simpleDateFormat.parse(formattedDate);
    dateInMillis=date.getTime();
  }
 catch (  ParseException e) {
    e.printStackTrace();
    dateInMillis=0;
  }
  return dateInMillis;
}

Fixed version (ground truth):
private long modTimeToMilis(String modTime){
  if (modTime.lastIndexOf("String_Node_Str") > 18 || modTime.lastIndexOf("String_Node_Str") > 18) {
    return modTimeZonedToMillis(modTime);
  }
  String[] dateTime=modTime.split("String_Node_Str");
  String yearMonthDay=dateTime[0];
  String hourMinuteSecond=dateTime[1].substring(0,dateTime[1].length() - 1);
  if (hourMinuteSecond.contains("String_Node_Str")) {
    int index=hourMinuteSecond.indexOf("String_Node_Str");
    hourMinuteSecond=hourMinuteSecond.substring(0,index);
  }
  String formattedDate=yearMonthDay + "String_Node_Str" + hourMinuteSecond+ "String_Node_Str";
  long dateInMillis;
  Date date;
  SimpleDateFormat simpleDateFormat=new SimpleDateFormat("String_Node_Str");
  try {
    date=simpleDateFormat.parse(formattedDate);
    dateInMillis=date.getTime();
  }
 catch (  ParseException e) {
    e.printStackTrace();
    dateInMillis=0;
  }
  return dateInMillis;
}
Program: 63190
Project: 63190
Buggy source:
@Override public void onStart(){
  super.onStart();
  if (showThumbnails) {
    startThumbnailService();
  }
  if (directoryObject.isContentValid()) {
    return;
  }
  if (fetchDirectoryTask != null) {
    fetchDirectoryTask.cancel(true);
  }
  swipeRefreshLayout.setRefreshing(true);
  fetchDirectoryTask=new FetchDirectoryContent(true).execute();
}

Fixed version (ground truth):
@Override public void onStart(){
  super.onStart();
  registerReceivers();
  if (showThumbnails) {
    startThumbnailService();
  }
  if (directoryObject.isContentValid()) {
    return;
  }
  if (fetchDirectoryTask != null) {
    fetchDirectoryTask.cancel(true);
  }
  swipeRefreshLayout.setRefreshing(true);
  fetchDirectoryTask=new FetchDirectoryContent(true).execute();
}
Program: 63191
Project: 63191
Buggy source:
@Override public void onStop(){
  super.onStop();
  if (showThumbnails) {
    Intent intent=new Intent(context,ThumbnailsLoadingService.class);
    context.stopService(intent);
  }
  LocalBroadcastManager.getInstance(context).unregisterReceiver(backgroundTaskBroadcastReceiver);
}

Fixed version (ground truth):
@Override public void onStop(){
  super.onStop();
  if (isThumbnailsServiceRunning) {
    Intent intent=new Intent(context,ThumbnailsLoadingService.class);
    context.stopService(intent);
    isThumbnailsServiceRunning=false;
  }
  LocalBroadcastManager.getInstance(context).unregisterReceiver(backgroundTaskBroadcastReceiver);
}
Program: 63192
Project: 63192
Buggy source:
private void startThumbnailService(){
  Intent serveIntent=new Intent(getContext(),ThumbnailsLoadingService.class);
  serveIntent.putExtra(ThumbnailsLoadingService.REMOTE_ARG,remoteName);
  context.startService(serveIntent);
}

Fixed version (ground truth):
private void startThumbnailService(){
  Intent serveIntent=new Intent(getContext(),ThumbnailsLoadingService.class);
  serveIntent.putExtra(ThumbnailsLoadingService.REMOTE_ARG,remoteName);
  context.startService(serveIntent);
  isThumbnailsServiceRunning=true;
}
Program: 63193
Project: 63193
Buggy source:
private void hideBottomBar(){
  View bottomBar=getView().findViewById(R.id.bottom_bar);
  Animation animation=AnimationUtils.loadAnimation(getContext(),R.anim.fade_out_animation);
  bottomBar.setAnimation(animation);
  bottomBar.setVisibility(View.GONE);
}

Fixed version (ground truth):
private void hideBottomBar(){
  View bottomBar=getView().findViewById(R.id.bottom_bar);
  if (bottomBar.getVisibility() != View.VISIBLE) {
    return;
  }
  Animation animation=AnimationUtils.loadAnimation(getContext(),R.anim.fade_out_animation);
  bottomBar.setAnimation(animation);
  bottomBar.setVisibility(View.GONE);
}
Program: 63195
Project: 63195
Buggy source:
/** 
 * Plugin registration.
 */
public static void registerWith(Registrar registrar){
  final MethodChannel channel=new MethodChannel(registrar.messenger(),"String_Node_Str");
  instance=new MusicFinderPlugin(registrar.activity(),channel);
  registrar.addRequestPermissionResultListener(instance);
  channel.setMethodCallHandler(instance);
}

Fixed version (ground truth):
/** 
 * Plugin registration.
 */
public static void registerWith(Registrar registrar){
  final MethodChannel channel=new MethodChannel(registrar.messenger(),"String_Node_Str");
  instance=new MusicFinderPlugin(registrar.activity(),channel);
  registrar.addRequestPermissionsResultListener(instance);
  channel.setMethodCallHandler(instance);
}
Program: 63196
Project: 63196
Buggy source:
@Override public boolean onRequestPermissionResult(int requestCode,String[] permissions,int[] grantResults){
  if (requestCode == REQUEST_CODE_STORAGE_PERMISSION) {
    for (int i=0; i < permissions.length; i++) {
      String permission=permissions[i];
      int grantResult=grantResults[i];
      if (permission.equals(Manifest.permission.CAMERA)) {
        if (grantResult == PackageManager.PERMISSION_GRANTED) {
          if (executeAfterPermissionGranted) {
            pendingResult.success(getData());
            pendingResult=null;
            arguments=null;
          }
        }
 else {
          setNoPermissionsError();
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onRequestPermissionResult(int requestCode,String[] permissions,int[] grantResults){
  if (requestCode == REQUEST_CODE_STORAGE_PERMISSION) {
    for (int i=0; i < permissions.length; i++) {
      String permission=permissions[i];
      int grantResult=grantResults[i];
      if (permission.equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
        if (grantResult == PackageManager.PERMISSION_GRANTED) {
          if (executeAfterPermissionGranted) {
            pendingResult.success(getData());
            pendingResult=null;
            arguments=null;
          }
        }
 else {
          setNoPermissionsError();
        }
      }
    }
  }
  return false;
}
Program: 63197
Project: 63197
Buggy source:
@Override public InputStream open(String path) throws IOException {
  return this.getClass().getResourceAsStream(path);
}

Fixed version (ground truth):
@Override public InputStream open(String path) throws IOException {
  return this.getClass().getResourceAsStream(parse(path));
}
Program: 63200
Project: 63200
Buggy source:
@Before public void setUp() throws Exception {
  fetchThreadData=new FetchThreadData<>(new Handler());
  fetchThreadData.start();
  fetchThreadData.getLooper();
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  Handler handler=mock(Handler.class);
  fetchThreadData=new FetchThreadData<>(handler);
  fetchThreadData.start();
  fetchThreadData.getLooper();
}
Program: 63202
Project: 63202
Buggy source:
@Override protected void onDestroy(){
  super.onDestroy();
  if (mAdapter.getCursor() != null) {
    mAdapter.getCursor().close();
  }
  database.close();
  mFetchThreadData.clearQueue();
  mFetchThreadData.quit();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  super.onDestroy();
  if (mAdapter.getCursor() != null) {
    mAdapter.getCursor().close();
  }
  database.close();
  mFetchThreadData.clearQueue();
}
Program: 63204
Project: 63204
Buggy source:
public void onItemClick(AdapterView<?> listView,View view,int position,long id){
  Cursor cursor=(Cursor)listView.getItemAtPosition(position);
  cityCountryName=cursor.getString(cursor.getColumnIndexOrThrow(CITY_COUNTRY_NAME));
  actvCityCountryName.setText(cityCountryName);
  mFetchThreadData.queueResponce(position,cityCountryName);
}

Fixed version (ground truth):
public void onItemClick(AdapterView<?> listView,View view,int position,long id){
  Cursor cursor=(Cursor)listView.getItemAtPosition(position);
  cityCountryName=cursor.getString(cursor.getColumnIndexOrThrow(CITY_COUNTRY_NAME));
  actvCityCountryName.setText(cityCountryName);
  mFetchThreadData.queueResponce(position,cityCountryName);
  hideKeyboard();
}
Program: 63205
Project: 63205
Buggy source:
void checkIncomplete(CompletableFuture<?> f){
  assertFalse(f.isDone());
  assertFalse(f.isCancelled());
  assertTrue(f.toString().matches("String_Node_Str"));
  try {
    assertNull(f.getNow(null));
  }
 catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
  try {
    f.get(randomExpiredTimeout(),randomTimeUnit());
    shouldThrow();
  }
 catch (  TimeoutException success) {
  }
catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
}

Fixed version (ground truth):
void checkIncomplete(CompletableFuture<?> f){
  assertFalse(f.isDone());
  assertFalse(f.isCancelled());
  assertTrue(f.toString().matches("String_Node_Str"));
  Object result=null;
  try {
    result=f.getNow(null);
  }
 catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
  assertNull(result);
  try {
    f.get(randomExpiredTimeout(),randomTimeUnit());
    shouldThrow();
  }
 catch (  TimeoutException success) {
  }
catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
}
Program: 63206
Project: 63206
Buggy source:
<T>void checkCompletedNormally(CompletableFuture<T> f,T value){
  checkTimedGet(f,value);
  try {
    assertEquals(value,f.join());
    assertEquals(value,f.getNow(null));
    assertEquals(value,f.get());
  }
 catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
  assertTrue(f.isDone());
  assertFalse(f.isCancelled());
  assertFalse(f.isCompletedExceptionally());
  assertTrue(f.toString().matches("String_Node_Str"));
}

Fixed version (ground truth):
<T>void checkCompletedNormally(CompletableFuture<T> f,T value){
  checkTimedGet(f,value);
  assertEquals(value,f.join());
  assertEquals(value,f.getNow(null));
  T result=null;
  try {
    result=f.get();
  }
 catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
  assertEquals(value,result);
  assertTrue(f.isDone());
  assertFalse(f.isCancelled());
  assertFalse(f.isCompletedExceptionally());
  assertTrue(f.toString().matches("String_Node_Str"));
}
Program: 63207
Project: 63207
Buggy source:
void checkCompletedNormally(CountedCompleter<?> a){
  assertTrue(a.isDone());
  assertFalse(a.isCancelled());
  assertTrue(a.isCompletedNormally());
  assertFalse(a.isCompletedAbnormally());
  assertNull(a.getException());
  assertNull(a.getRawResult());
{
    Thread.currentThread().interrupt();
    long startTime=System.nanoTime();
    assertNull(a.join());
    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
    Thread.interrupted();
  }
{
    Thread.currentThread().interrupt();
    long startTime=System.nanoTime();
    a.quietlyJoin();
    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
    Thread.interrupted();
  }
  assertFalse(a.cancel(false));
  assertFalse(a.cancel(true));
  try {
    assertNull(a.get());
    assertNull(a.get(randomTimeout(),randomTimeUnit()));
  }
 catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
}

Fixed version (ground truth):
void checkCompletedNormally(CountedCompleter<?> a){
  assertTrue(a.isDone());
  assertFalse(a.isCancelled());
  assertTrue(a.isCompletedNormally());
  assertFalse(a.isCompletedAbnormally());
  assertNull(a.getException());
  assertNull(a.getRawResult());
{
    Thread.currentThread().interrupt();
    long startTime=System.nanoTime();
    assertNull(a.join());
    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
    Thread.interrupted();
  }
{
    Thread.currentThread().interrupt();
    long startTime=System.nanoTime();
    a.quietlyJoin();
    assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
    Thread.interrupted();
  }
  assertFalse(a.cancel(false));
  assertFalse(a.cancel(true));
  Object v1=null, v2=null;
  try {
    v1=a.get();
    v2=a.get(randomTimeout(),randomTimeUnit());
  }
 catch (  Throwable fail) {
    threadUnexpectedException(fail);
  }
  assertNull(v1);
  assertNull(v2);
}