nus-yam/ex-repair huggingface dataset:
Program: 69028
Project: 69028
Buggy source:
public static BigInteger getWei(BigDecimal realNumber,BigInteger tokenId,RedisTemplate redisTemplate){
  if (null == tokenId || BigInteger.ZERO.equals(tokenId)) {
    return Convert.toWei(realNumber,Convert.Unit.ETHER).toBigInteger();
  }
 else {
    Convert.Unit unit=(Convert.Unit)redisTemplate.opsForValue().get(RedisConstants.UNIT + "String_Node_Str" + tokenId);
    return Convert.toWei(realNumber,unit).toBigInteger();
  }
}

Fixed version (ground truth):
public static BigInteger getWei(BigDecimal realNumber,BigInteger tokenId,RedisTemplate redisTemplate){
  if (null == tokenId || BigInteger.ZERO.equals(tokenId)) {
    return Convert.toWei(realNumber,Convert.Unit.ETHER).toBigInteger();
  }
 else {
    String name=redisTemplate.opsForValue().get(RedisConstants.UNIT + "String_Node_Str" + tokenId).toString();
    Convert.Unit unit=Convert.Unit.valueOf(name);
    return Convert.toWei(realNumber,unit).toBigInteger();
  }
}
Program: 69029
Project: 69029
Buggy source:
private void newListen() throws InterruptedException {
  Subscription subscribe=web3j.transactionObservable().subscribe(tx -> listenTx(tx,false),getOnError());
  while (true) {
    if (null == subscribe || subscribe.isUnsubscribed()) {
      Thread.sleep(1000);
      newListen();
    }
  }
}

Fixed version (ground truth):
private void newListen() throws InterruptedException {
  Subscription subscribe=web3j.transactionObservable().subscribe(tx -> listenTx(tx,false),getOnError());
  while (true) {
    if (null == subscribe || subscribe.isUnsubscribed()) {
      Thread.sleep(10000);
      newListen();
    }
  }
}
Program: 69030
Project: 69030
Buggy source:
private void historyListen() throws InterruptedException {
  BigInteger lastBlockNumber=(BigInteger)redisTemplate.opsForValue().get(RedisConstants.LAST_BOLCK_NUMBER);
  if (null == lastBlockNumber) {
    lastBlockNumber=BigInteger.ZERO;
  }
  Subscription subscription=web3j.replayTransactionsObservable(DefaultBlockParameter.valueOf(lastBlockNumber),DefaultBlockParameterName.LATEST).subscribe(tx -> listenTx(tx,true),getOnError());
  while (true) {
    if (null == subscription || subscription.isUnsubscribed()) {
      historyListen();
      Thread.sleep(1000);
    }
  }
}

Fixed version (ground truth):
private void historyListen() throws InterruptedException {
  BigInteger lastBlockNumber=(BigInteger)redisTemplate.opsForValue().get(RedisConstants.LAST_BOLCK_NUMBER);
  if (null == lastBlockNumber) {
    lastBlockNumber=BigInteger.ZERO;
  }
  Subscription subscription=web3j.replayTransactionsObservable(DefaultBlockParameter.valueOf(lastBlockNumber),DefaultBlockParameterName.LATEST).subscribe(tx -> listenTx(tx,true),getOnError());
  while (true) {
    if (null == subscription || subscription.isUnsubscribed()) {
      Thread.sleep(10000);
      historyListen();
    }
  }
}
Program: 69031
Project: 69031
Buggy source:
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getWithdrawStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  projectMapper.retireBalance(id);
  projectMapper.retireToken(id,config.getId());
  orderService.retireToken(id,CommonConstants.ORDER_STATUS_RETIRE);
}

Fixed version (ground truth):
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getWithdrawStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  Orders orders=new Orders();
  orders.setProjectId(id);
  if (orderMapper.selectCount(orders) > 0) {
    projectMapper.retireBalance(id);
    projectMapper.retireToken(id,config.getId());
    orderService.retireToken(id,CommonConstants.ORDER_STATUS_RETIRE);
  }
}
Program: 69032
Project: 69032
Buggy source:
private void newListen() throws InterruptedException {
  Subscription subscribe=web3j.transactionObservable().subscribe(tx -> listenTx(tx,false),getOnError());
  while (true) {
    if (null == subscribe || subscribe.isUnsubscribed()) {
      newListen();
      Thread.sleep(1000);
    }
  }
}

Fixed version (ground truth):
private void newListen() throws InterruptedException {
  Subscription subscribe=web3j.transactionObservable().subscribe(tx -> listenTx(tx,false),getOnError());
  while (true) {
    if (null == subscribe || subscribe.isUnsubscribed()) {
      Thread.sleep(1000);
      newListen();
    }
  }
}
Program: 69033
Project: 69033
Buggy source:
@Override @Async public void run(String... args) throws InterruptedException {
  transactionService.initConfig();
  transactionService.startListen();
}

Fixed version (ground truth):
@Override @Async public void run(String... args) throws InterruptedException {
  transactionService.initConfig();
  transactionService.startHistory();
  transactionService.startListen();
}
Program: 69034
Project: 69034
Buggy source:
public void startListen() throws InterruptedException {
  try {
    historyListen();
    newListen();
  }
 catch (  Exception e) {
    Thread.sleep(10000);
    startListen();
  }
}

Fixed version (ground truth):
@Async public void startListen() throws InterruptedException {
  try {
    newListen();
  }
 catch (  Exception e) {
    Thread.sleep(10000);
    startListen();
  }
}
Program: 69035
Project: 69035
Buggy source:
public static String getTo(Transaction tx){
  try {
    String to=tx.getTo();
    if (null == to) {
      return to;
    }
    if (ETH_FLAG.equalsIgnoreCase(tx.getInput())) {
      return to;
    }
    if (isContractTx(tx)) {
      return tx.getInput().substring(34,74);
    }
    return null;
  }
 catch (  Exception e) {
    return null;
  }
}

Fixed version (ground truth):
public static String getTo(Transaction tx){
  try {
    String to=tx.getTo();
    if (null == to) {
      return to;
    }
    if (ETH_FLAG.equalsIgnoreCase(tx.getInput())) {
      return to;
    }
    if (isContractTx(tx)) {
      return "String_Node_Str" + tx.getInput().substring(34,74);
    }
    return null;
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 69036
Project: 69036
Buggy source:
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getWithdrawStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  projectMapper.retireBalance(id);
  projectMapper.retireToken(id,config.getId());
  orderService.updateStatusByProject(id,CommonConstants.ORDER_STATUS_RETIRE);
}

Fixed version (ground truth):
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getWithdrawStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  projectMapper.retireBalance(id);
  projectMapper.retireToken(id,config.getId());
  orderService.retireToken(id,CommonConstants.ORDER_STATUS_RETIRE);
}
Program: 69037
Project: 69037
Buggy source:
@Update("String_Node_Str") void retireBalance(@Param("String_Node_Str") BigInteger userId,@Param("String_Node_Str") BigInteger projectId);

Fixed version (ground truth):
@Update("String_Node_Str") void retireBalance(@Param("String_Node_Str") BigInteger projectId);
Program: 69038
Project: 69038
Buggy source:
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getRechargeStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  orderService.updateStatusByProject(id,CommonConstants.ORDER_STATUS_RETIRE);
  projectMapper.retireBalance(getUserId(),id);
}

Fixed version (ground truth):
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getRechargeStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  projectMapper.retireBalance(id);
  projectMapper.retireToken(id,config.getId());
  orderService.updateStatusByProject(id,CommonConstants.ORDER_STATUS_RETIRE);
}
Program: 69039
Project: 69039
Buggy source:
public void withdraw(WithdrawDTO withdrawDTO){
  checkAccount(withdrawDTO);
  Config config=getConfig(withdrawDTO.getTokenName());
  Assert.notNull(config,CommonConstants.TOKEN_ERR);
  checkCanWithdraw(withdrawDTO,config);
  checkEthBalance(withdrawDTO,config);
  Transaction transaction=new Transaction();
  transaction.setStatus(0);
  transaction.setNumber(withdrawDTO.getNumber());
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_WITHDRAW));
  transaction.setPoundage(config.getPoundage());
  transaction.setRealNumber(withdrawDTO.getNumber().subtract(BigDecimal.valueOf(config.getPoundage())));
  transaction.setToAddress(withdrawDTO.getAddress());
  transaction.setType(CommonConstants.WITHDRAW);
  transaction.setUserId(getUserId());
  transaction.setTokenId(config.getId());
  transaction.setFromAddress(defaultUser);
  transactionMapper.insert(transaction);
  capitalMapper.updateBalance(getUserId(),config.getId(),BigDecimal.ZERO.subtract(withdrawDTO.getNumber()));
}

Fixed version (ground truth):
public void withdraw(WithdrawDTO withdrawDTO){
  checkAccount(withdrawDTO);
  Config config=getConfig(withdrawDTO.getTokenName());
  Assert.notNull(config,CommonConstants.TOKEN_ERR);
  checkCanWithdraw(withdrawDTO,config);
  checkEthBalance(withdrawDTO,config);
  Transaction transaction=new Transaction();
  transaction.setStatus(0);
  transaction.setNumber(withdrawDTO.getNumber());
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_WITHDRAW));
  transaction.setPoundage(config.getPoundage());
  transaction.setRealNumber(withdrawDTO.getNumber().subtract(BigDecimal.valueOf(config.getPoundage())));
  transaction.setToAddress(withdrawDTO.getAddress());
  transaction.setType(CommonConstants.WITHDRAW);
  transaction.setUserId(getUserId());
  transaction.setTokenId(config.getId());
  transaction.setFromAddress(defaultUser);
  transactionMapper.insert(transaction);
  capitalMapper.updateBalance(getUserId(),config.getId(),BigDecimal.ZERO.subtract(withdrawDTO.getNumber()));
  String key=RedisConstants.TODAY_USER + "String_Node_Str" + withdrawDTO.getTokenName()+ "String_Node_Str"+ getUserId();
  BigDecimal use=(BigDecimal)redisTemplate.opsForValue().get(key);
  use=use == null ? withdrawDTO.getNumber() : use.add(withdrawDTO.getNumber());
  redisTemplate.opsForValue().set(key,use);
}
Program: 69040
Project: 69040
Buggy source:
public TokenVO login(AdminDTO adminDTO){
  String username=adminDTO.getUsername();
  Admin admin=new Admin();
  admin.setUsername(username);
  admin=adminMapper.selectOne(admin);
  Assert.notNull(admin,MessageConstants.getMsg("String_Node_Str"));
  boolean result=encoder.matches(adminDTO.getPassword(),admin.getPassword());
  Assert.isTrue(result,MessageConstants.getMsg("String_Node_Str"));
  Assert.isTrue(!MessageConstants.getMsg("String_Node_Str").equals(admin.getStatus()),"String_Node_Str");
  redisTemplate.opsForValue().set(RedisConstants.USER_STATUS,admin.getStatus());
  String token=JwtHelper.createToken(username,admin.getId());
  String refreshToken=JwtHelper.createRefresh(username,admin.getId());
  return new TokenVO(token,refreshToken);
}

Fixed version (ground truth):
public TokenVO login(AdminDTO adminDTO){
  String username=adminDTO.getUsername();
  Admin admin=new Admin();
  admin.setUsername(username);
  admin=adminMapper.selectOne(admin);
  Assert.notNull(admin,MessageConstants.getMsg("String_Node_Str"));
  boolean result=encoder.matches(adminDTO.getPassword(),admin.getPassword());
  Assert.isTrue(result,MessageConstants.getMsg("String_Node_Str"));
  Assert.isTrue(!CommonConstants.USER_FREEZE.equals(admin.getStatus()),"String_Node_Str");
  redisTemplate.opsForValue().set(RedisConstants.USER_STATUS,admin.getStatus());
  String token=JwtHelper.createToken(username,admin.getId());
  String refreshToken=JwtHelper.createRefresh(username,admin.getId());
  return new TokenVO(token,refreshToken);
}
Program: 69041
Project: 69041
Buggy source:
public void buy(BuyDTO buyDTO){
  Account account=accountService.getAccount(getUserId());
  Assert.isTrue(encoder.matches(buyDTO.getTransactionPassword(),account.getTransactionPassword()),MessageConstants.getMsg("String_Node_Str"));
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,MessageConstants.getMsg("String_Node_Str"));
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) <= 0,MessageConstants.getMsg("String_Node_Str"));
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,MessageConstants.getMsg("String_Node_Str"));
  addOrder(buyDTO,balance);
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
  String key=RedisConstants.USER_PROJECTS + "String_Node_Str" + getUserId();
  redisTemplate.opsForValue().set(key,orderMapper.getUserProject(getUserId()));
}

Fixed version (ground truth):
public void buy(BuyDTO buyDTO){
  Account account=accountService.getAccount(getUserId());
  Assert.isTrue(encoder.matches(buyDTO.getTransactionPassword(),account.getTransactionPassword()),MessageConstants.getMsg("String_Node_Str"));
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,MessageConstants.getMsg("String_Node_Str"));
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) <= 0,MessageConstants.getMsg("String_Node_Str"));
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,MessageConstants.getMsg("String_Node_Str"));
  addOrder(buyDTO,balance);
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
  sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.compareTo(project.getEthNumber()) <= 0,MessageConstants.getMsg("String_Node_Str"));
  String key=RedisConstants.USER_PROJECTS + "String_Node_Str" + getUserId();
  redisTemplate.opsForValue().set(key,orderMapper.getUserProject(getUserId()));
}
Program: 69042
Project: 69042
Buggy source:
@Bean public OkHttpClient okHttpClient() throws IOException {
  OkHttpClient.Builder builder=new OkHttpClient.Builder();
  builder.connectTimeout(120,TimeUnit.SECONDS).readTimeout(120,TimeUnit.SECONDS).writeTimeout(120,TimeUnit.SECONDS).retryOnConnectionFailure(true).addInterceptor(new Interceptor(){
    @Autowired TransactionService transactionService;
    @Override public Response intercept(    Chain chain) throws IOException {
      Request originalRequest=chain.request();
      Request requestWithUserAgent=originalRequest.newBuilder().build();
      Response result=null;
      try {
        result=chain.proceed(requestWithUserAgent);
      }
 catch (      Exception e) {
        e.printStackTrace();
        try {
          transactionService.startListen();
          return null;
        }
 catch (        InterruptedException e1) {
          e1.printStackTrace();
        }
      }
      return result;
    }
  }
);
  return builder.build();
}

Fixed version (ground truth):
@Bean public OkHttpClient okHttpClient() throws IOException {
  OkHttpClient.Builder builder=new OkHttpClient.Builder();
  builder.connectTimeout(120,TimeUnit.SECONDS).readTimeout(120,TimeUnit.SECONDS).writeTimeout(120,TimeUnit.SECONDS).retryOnConnectionFailure(true).addInterceptor(new Interceptor(){
    TransactionService transactionService=SpringContextUtil.getBean("String_Node_Str");
    @Override public Response intercept(    Chain chain) throws IOException {
      Request originalRequest=chain.request();
      Request requestWithUserAgent=originalRequest.newBuilder().build();
      Response result=null;
      try {
        result=chain.proceed(requestWithUserAgent);
      }
 catch (      Exception e) {
        e.printStackTrace();
        try {
          transactionService.startListen();
          return null;
        }
 catch (        InterruptedException e1) {
          e1.printStackTrace();
        }
      }
      return result;
    }
  }
);
  return builder.build();
}
Program: 69043
Project: 69043
Buggy source:
private void addressHandler(org.web3j.protocol.core.methods.response.Transaction tx){
  String to=Web3jUtil.getTo(tx);
  String key=RedisConstants.LISTEN_ETH_ADDR + "String_Node_Str" + to;
  String hash=tx.getHash();
  BigInteger userId=(BigInteger)redisTemplate.opsForValue().get(key);
  if (null == userId) {
    return;
  }
  if (existHash(hash)) {
    return;
  }
  BigInteger tokenId=getTokenId(tx);
  Config config=configService.get(tokenId);
  if (null == config) {
    return;
  }
  Transaction transaction=new Transaction();
  transaction.setHash(hash);
  transaction.setUserId(userId);
  transaction.setTokenId(tokenId);
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_RECHARGE));
  transaction.setType(CommonConstants.RECHARGE);
  transaction.setStatus(CommonConstants.STATUS_SUCCESS);
  transaction.setToAddress(to);
  transaction.setFromAddress(tx.getFrom());
  transaction.setNumber(Web3jUtil.getValue(tx.getValue(),transaction.getTokenId(),redisTemplate));
  transaction.setPoundage(0f);
  transaction.setRealNumber(transaction.getNumber());
  transactionMapper.insertSelective(transaction);
  updateBalance(transaction);
  this.transferBalance(transaction,coldUser);
}

Fixed version (ground truth):
private void addressHandler(org.web3j.protocol.core.methods.response.Transaction tx){
  String to=Web3jUtil.getTo(tx);
  String key=RedisConstants.LISTEN_ETH_ADDR + "String_Node_Str" + to;
  String hash=tx.getHash();
  BigInteger userId=(BigInteger)redisTemplate.opsForValue().get(key);
  if (null == userId) {
    return;
  }
  if (existHash(hash)) {
    return;
  }
  BigInteger tokenId=getTokenId(tx);
  Config config=configService.get(tokenId);
  if (null == config) {
    return;
  }
  Transaction transaction=new Transaction();
  transaction.setHash(hash);
  transaction.setUserId(userId);
  transaction.setTokenId(tokenId);
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_RECHARGE));
  transaction.setType(CommonConstants.RECHARGE);
  transaction.setStatus(CommonConstants.STATUS_SUCCESS);
  transaction.setToAddress(to);
  transaction.setFromAddress(tx.getFrom());
  BigInteger value=Web3jUtil.isContractTx(tx) ? new BigInteger(tx.getInput().substring(tx.getInput().length() - 64),16) : tx.getValue();
  transaction.setNumber(Web3jUtil.getValue(value,transaction.getTokenId(),redisTemplate));
  transaction.setPoundage(0f);
  transaction.setRealNumber(transaction.getNumber());
  transactionMapper.insertSelective(transaction);
  updateBalance(transaction);
  this.transferBalance(transaction,coldUser);
}
Program: 69044
Project: 69044
Buggy source:
private void newListen() throws InterruptedException {
  Subscription subscribe=web3j.transactionObservable().subscribe(tx -> listenTx(tx,false),getOnError());
  while (true) {
    if (null == subscribe || subscribe.isUnsubscribed()) {
      Thread.sleep(10000);
      newListen();
    }
  }
}

Fixed version (ground truth):
private void newListen() throws InterruptedException {
  Subscription subscribe=null;
  try {
    subscribe=web3j.transactionObservable().subscribe(tx -> listenTx(tx,false),getOnError());
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  while (true) {
    if (null == subscribe || subscribe.isUnsubscribed()) {
      Thread.sleep(10000);
      newListen();
    }
  }
}
Program: 69045
Project: 69045
Buggy source:
public PageInfo<TransactionVO> transaction(TransactionDTO transactionDTO){
  transactionDTO.setOrderId(StringUtils.isEmpty(transactionDTO.getOrderId()) ? null : transactionDTO.getOrderId());
  Transaction transaction=(Transaction)BeanUtil.copyProperties(transactionDTO,new Transaction());
  List<Transaction> list=transactionMapper.select(transaction);
  PageInfo pageInfo=new PageInfo(list);
  return (PageInfo<TransactionVO>)BeanUtil.beanList2VOList(pageInfo,TransactionVO.class);
}

Fixed version (ground truth):
public PageInfo<TransactionVO> transaction(TransactionDTO transactionDTO){
  transactionDTO.setOrderId(StringUtils.isEmpty(transactionDTO.getOrderId()) ? null : transactionDTO.getOrderId());
  Transaction transaction=(Transaction)BeanUtil.copyProperties(transactionDTO,new Transaction());
  List<Transaction> list=transactionMapper.select(transaction);
  PageInfo pageInfo=new PageInfo(list);
  PageInfo<TransactionVO> result=(PageInfo<TransactionVO>)BeanUtil.beanList2VOList(pageInfo,TransactionVO.class);
  result.getList().forEach(obj -> obj.setTokenName(configService.getNameByTokenId(obj.getTokenId())));
  return result;
}
Program: 69046
Project: 69046
Buggy source:
public void update(Config config){
  insert(config);
  configMapper.updateByPrimaryKeySelective(config);
}

Fixed version (ground truth):
public void update(Config config){
  insert(config);
  configMapper.updateByPrimaryKeySelective(config);
  setUnit(config.getId(),config.getDecimals());
}
Program: 69047
Project: 69047
Buggy source:
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getRechargeStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  projectMapper.retireBalance(id);
  projectMapper.retireToken(id,config.getId());
  orderService.updateStatusByProject(id,CommonConstants.ORDER_STATUS_RETIRE);
}

Fixed version (ground truth):
public void retire(BigInteger id,Integer retire){
  Project project=getNotNullById(id);
  Config config=configService.getConfigByTokenName(project.getTokenName());
  Boolean canRetire=project.getStatus().equals(2) && project.getRetire().equals(0) && config.getWithdrawStatus().equals(0);
  Assert.isTrue(canRetire,MessageConstants.CANNOT_RETIRE);
  project.setRetire(1);
  projectMapper.updateByPrimaryKeySelective(project);
  projectMapper.retireBalance(id);
  projectMapper.retireToken(id,config.getId());
  orderService.updateStatusByProject(id,CommonConstants.ORDER_STATUS_RETIRE);
}
Program: 69048
Project: 69048
Buggy source:
@Override @Async public void run(String... args) throws InterruptedException {
  transactionService.startListen();
}

Fixed version (ground truth):
@Override @Async public void run(String... args) throws InterruptedException {
  transactionService.initConfig();
  transactionService.startListen();
}
Program: 69049
Project: 69049
Buggy source:
@Update("String_Node_Str") void retireToken(BigInteger id,Integer orderStatusRetire);

Fixed version (ground truth):
@Update("String_Node_Str") void retireToken(@Param("String_Node_Str") BigInteger projectId,@Param("String_Node_Str") Integer orderStatus);
Program: 69050
Project: 69050
Buggy source:
public Map<String,String> doGetSignature(String dir) throws UnsupportedEncodingException {
  String host="String_Node_Str" + bucketName + "String_Node_Str"+ endpoint;
  long expireTime=30;
  long expireEndTime=System.currentTimeMillis() + expireTime * 1000;
  Date expiration=new Date(expireEndTime);
  PolicyConditions policyConds=new PolicyConditions();
  policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE,0,1048576000);
  policyConds.addConditionItem(MatchMode.StartWith,PolicyConditions.COND_KEY,dir);
  String postPolicy=ossClient.generatePostPolicy(expiration,policyConds);
  byte[] binaryData=postPolicy.getBytes("String_Node_Str");
  String encodedPolicy=BinaryUtil.toBase64String(binaryData);
  String postSignature=ossClient.calculatePostSignature(postPolicy);
  Map<String,String> responseMap=new LinkedHashMap<String,String>();
  responseMap.put("String_Node_Str",accessKeyId);
  responseMap.put("String_Node_Str",encodedPolicy);
  responseMap.put("String_Node_Str",postSignature);
  responseMap.put("String_Node_Str",dir);
  responseMap.put("String_Node_Str",host);
  responseMap.put("String_Node_Str",String.valueOf(expireEndTime / 1000));
  return responseMap;
}

Fixed version (ground truth):
public Map<String,String> doGetSignature(String dir) throws UnsupportedEncodingException {
  String host="String_Node_Str" + bucketName + "String_Node_Str"+ endpoint;
  long expireTime=300;
  long expireEndTime=System.currentTimeMillis() + expireTime * 1000;
  Date expiration=new Date(expireEndTime);
  PolicyConditions policyConds=new PolicyConditions();
  policyConds.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE,0,1048576000);
  policyConds.addConditionItem(MatchMode.StartWith,PolicyConditions.COND_KEY,dir);
  String postPolicy=ossClient.generatePostPolicy(expiration,policyConds);
  byte[] binaryData=postPolicy.getBytes("String_Node_Str");
  String encodedPolicy=BinaryUtil.toBase64String(binaryData);
  String postSignature=ossClient.calculatePostSignature(postPolicy);
  Map<String,String> responseMap=new LinkedHashMap<String,String>();
  responseMap.put("String_Node_Str",accessKeyId);
  responseMap.put("String_Node_Str",encodedPolicy);
  responseMap.put("String_Node_Str",postSignature);
  responseMap.put("String_Node_Str",dir);
  responseMap.put("String_Node_Str",host);
  responseMap.put("String_Node_Str",String.valueOf(expireEndTime / 1000));
  return responseMap;
}
Program: 69051
Project: 69051
Buggy source:
public TokenVO login(AdminDTO adminDTO){
  String username=adminDTO.getUsername();
  Admin admin=new Admin();
  String encrypt=encoder.encode(adminDTO.getPassword());
  admin.setUsername(username);
  admin=adminMapper.selectOne(admin);
  boolean result=encoder.matches(adminDTO.getPassword(),encrypt);
  Assert.isTrue(result,MessageConstants.PWD_ERR);
  Assert.isTrue(!CommonConstants.USER_FREEZE.equals(admin.getStatus()),"String_Node_Str");
  redisTemplate.opsForValue().set(RedisConstants.USER_STATUS,admin.getStatus());
  String token=JwtHelper.createToken(username,admin.getId());
  String refreshToken=JwtHelper.createRefresh(username,admin.getId());
  return new TokenVO(token,refreshToken);
}

Fixed version (ground truth):
public TokenVO login(AdminDTO adminDTO){
  String username=adminDTO.getUsername();
  Admin admin=new Admin();
  String encrypt=encoder.encode(adminDTO.getPassword());
  admin.setUsername(username);
  admin=adminMapper.selectOne(admin);
  Assert.notNull(admin,MessageConstants.PWD_ERR);
  boolean result=encoder.matches(adminDTO.getPassword(),encrypt);
  Assert.isTrue(result,MessageConstants.PWD_ERR);
  Assert.isTrue(!CommonConstants.USER_FREEZE.equals(admin.getStatus()),"String_Node_Str");
  redisTemplate.opsForValue().set(RedisConstants.USER_STATUS,admin.getStatus());
  String token=JwtHelper.createToken(username,admin.getId());
  String refreshToken=JwtHelper.createRefresh(username,admin.getId());
  return new TokenVO(token,refreshToken);
}
Program: 69052
Project: 69052
Buggy source:
String getOrderId(String type){
  Long sid=redisTemplate.opsForValue().increment(type,1);
  return type + sid;
}

Fixed version (ground truth):
String getOrderId(String type){
  Long sid=redisTemplate.opsForValue().increment(type,1);
  return type + String.format("String_Node_Str",sid);
}
Program: 69053
Project: 69053
Buggy source:
public void buy(BuyDTO buyDTO){
  Config config=new Config();
  config.setProjectId(buyDTO.getProjectId());
  config=configMapper.selectOne(config);
  Assert.notNull(config,CommonConstants.PROJECT_NOT_EXIST);
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,CommonConstants.PROJECT_NOT_EXIST);
  Capital capital=new Capital();
  capital.setUserId(getUserId());
  capital.setTokenId(config.getId());
  Capital capitalTemp=capitalMapper.selectOne(capital);
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  if (null == capitalTemp) {
    capitalTemp=capital;
    capitalTemp.setBalance(balance);
    capitalMapper.insert(capital);
  }
 else {
    capitalMapper.updateBalance(getUserId(),config.getId(),balance);
  }
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,CommonConstants.ETH_NOT_ENOUGH);
  addOrder(buyDTO,balance);
  Account account=accountService.getAccount(getUserId());
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : orderNum++;
  account.setOrderNum(orderNum);
  accountService.update(account);
}

Fixed version (ground truth):
public void buy(BuyDTO buyDTO){
  Config config=new Config();
  config.setProjectId(buyDTO.getProjectId());
  config=configMapper.selectOne(config);
  Assert.notNull(config,CommonConstants.PROJECT_NOT_EXIST);
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,CommonConstants.PROJECT_NOT_EXIST);
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) < 0,MessageConstants.ETH_OVER);
  Capital capital=new Capital();
  capital.setUserId(getUserId());
  capital.setTokenId(config.getId());
  Capital capitalTemp=capitalMapper.selectOne(capital);
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  if (null == capitalTemp) {
    capitalTemp=capital;
    capitalTemp.setBalance(balance);
    capitalMapper.insert(capital);
  }
 else {
    capitalMapper.updateBalance(getUserId(),config.getId(),balance);
  }
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,CommonConstants.ETH_NOT_ENOUGH);
  addOrder(buyDTO,balance);
  Account account=accountService.getAccount(getUserId());
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
}
Program: 69054
Project: 69054
Buggy source:
private void updateSold(BigInteger projectId,BigDecimal ethNumber,BigDecimal balance){
  ProjectSold projectSold=new ProjectSold();
  projectSold.setId(projectId);
  projectSold.setSoldEth(ethNumber);
  projectMapper.updateSoldBalance(projectSold);
}

Fixed version (ground truth):
private void updateSold(BigInteger projectId,BigDecimal ethNumber,BigDecimal balance){
  Orders orders=new Orders();
  orders.setUserId(getUserId());
  Integer orderNum=orderMapper.selectCount(orders);
  Integer buyerNum=orderNum == 1 ? 1 : 0;
  ProjectSold projectSold=new ProjectSold();
  projectSold.setId(projectId);
  projectSold.setSoldEth(ethNumber);
  projectSold.setBuyerNum(buyerNum);
  projectMapper.updateSoldBalance(projectSold);
}
Program: 69055
Project: 69055
Buggy source:
public void withdraw(WithdrawDTO withdrawDTO){
  checkAccount(withdrawDTO);
  Config config=getConfig(withdrawDTO.getTokenName());
  Assert.notNull(config,CommonConstants.TOKEN_ERR);
  checkCanWithdraw(withdrawDTO,config);
  checkEthBalance(withdrawDTO,config);
  Transaction transaction=new Transaction();
  transaction.setStatus(0);
  transaction.setNumber(withdrawDTO.getNumber());
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_WITHDRAW));
  transaction.setPoundage(config.getPoundage());
  transaction.setRealNumber(withdrawDTO.getNumber().subtract(BigDecimal.valueOf(config.getPoundage())));
  transaction.setToAddress(withdrawDTO.getAddress());
  transaction.setType(CommonConstants.WITHDRAW);
  transaction.setUserId(getUserId());
  transaction.setFromAddress(defaultUser);
  transactionMapper.insert(transaction);
  capitalMapper.updateBalance(getUserId(),config.getId(),BigDecimal.ZERO.multiply(withdrawDTO.getNumber()));
}

Fixed version (ground truth):
public void withdraw(WithdrawDTO withdrawDTO){
  checkAccount(withdrawDTO);
  Config config=getConfig(withdrawDTO.getTokenName());
  Assert.notNull(config,CommonConstants.TOKEN_ERR);
  checkCanWithdraw(withdrawDTO,config);
  checkEthBalance(withdrawDTO,config);
  Transaction transaction=new Transaction();
  transaction.setStatus(0);
  transaction.setNumber(withdrawDTO.getNumber());
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_WITHDRAW));
  transaction.setPoundage(config.getPoundage());
  transaction.setRealNumber(withdrawDTO.getNumber().subtract(BigDecimal.valueOf(config.getPoundage())));
  transaction.setToAddress(withdrawDTO.getAddress());
  transaction.setType(CommonConstants.WITHDRAW);
  transaction.setUserId(getUserId());
  transaction.setTokenId(config.getId());
  transaction.setFromAddress(defaultUser);
  transactionMapper.insert(transaction);
  capitalMapper.updateBalance(getUserId(),config.getId(),BigDecimal.ZERO.multiply(withdrawDTO.getNumber()));
}
Program: 69056
Project: 69056
Buggy source:
public void updateStatus(BigInteger orderId,Integer orderStatus){
  Orders orders=new Orders();
  orders.setId(orderId);
  orders=orderMapper.selectByPrimaryKey(orderId);
  Assert.isTrue(orders.getOrderStatus() == 0,MessageConstants.CANNOT_CANCEL);
  orders.setOrderStatus(orderStatus);
  orderMapper.updateByPrimaryKeySelective(orders);
  tokenSoldMapper.updateEth(orders.getProjectId(),orders.getEthNumber());
}

Fixed version (ground truth):
public void updateStatus(BigInteger orderId,Integer orderStatus){
  Orders orders=new Orders();
  orders.setId(orderId);
  orders=orderMapper.selectByPrimaryKey(orderId);
  Assert.isTrue(orders.getOrderStatus() == 0,MessageConstants.CANNOT_CANCEL);
  orders.setOrderStatus(orderStatus);
  orderMapper.updateByPrimaryKeySelective(orders);
  tokenSoldMapper.updateEth(orders.getProjectId(),orders.getEthNumber());
  capitalMapper.updateBalance(orders.getUserId(),BigInteger.ZERO,orders.getEthNumber());
}
Program: 69057
Project: 69057
Buggy source:
@Async public void transferBalance(Transaction transaction){
  try {
    EthGetBalance result=web3j.ethGetBalance(transaction.getToAddress(),DefaultBlockParameterName.LATEST).send();
    BigInteger needBalance=TransactionService.DEFAULT_GAS_LIMIT.multiply(TransactionService.DEFAULT_GAS_PRICE);
    BigInteger sendBalance=result.getBalance().subtract(needBalance);
    if (sendGasIfNull(transaction,result,needBalance)) {
      return;
    }
    String contractAddress=getContractAddressByTokenId(transaction);
    if (!transaction.getTokenId().equals(0)) {
      sendBalance=contractService.balanceOf(contractAddress,transaction.getToAddress());
    }
    sendTransaction(transaction.getToAddress(),defaultUser,contractAddress,sendBalance,false);
  }
 catch (  Exception e) {
    e.printStackTrace();
    log.error(e.getMessage());
  }
}

Fixed version (ground truth):
@Async public void transferBalance(Transaction transaction){
  try {
    EthGetBalance result=web3j.ethGetBalance(transaction.getToAddress(),DefaultBlockParameterName.LATEST).send();
    BigInteger needBalance=TransactionService.DEFAULT_GAS_LIMIT.multiply(TransactionService.DEFAULT_GAS_PRICE);
    BigInteger sendBalance=result.getBalance().subtract(needBalance);
    if (sendGasIfNull(transaction,result,needBalance)) {
      return;
    }
    String contractAddress=getContractAddressByTokenId(transaction);
    if (!transaction.getTokenId().equals(BigInteger.ZERO)) {
      sendBalance=contractService.balanceOf(contractAddress,transaction.getToAddress());
    }
    sendTransaction(transaction.getToAddress(),defaultUser,contractAddress,sendBalance,false);
  }
 catch (  Exception e) {
    e.printStackTrace();
    log.error(e.getMessage());
  }
}
Program: 69058
Project: 69058
Buggy source:
private void updateBalance(Transaction transaction){
  Capital capital=new Capital();
  capital.setUserId(transaction.getUserId());
  capital.setTokenId(transaction.getTokenId());
  Capital capitalTemp=capitalMapper.selectOne(capital);
  if (null == capitalTemp) {
    capitalMapper.insert(capital);
  }
  capitalMapper.updateBalance(transaction.getUserId(),transaction.getTokenId(),transaction.getNumber());
}

Fixed version (ground truth):
private void updateBalance(Transaction transaction){
  Capital capital=new Capital();
  capital.setUserId(transaction.getUserId());
  capital.setTokenId(transaction.getTokenId());
  Capital capitalTemp=capitalMapper.selectOne(capital);
  if (null == capitalTemp) {
    capital.setBalance(transaction.getNumber());
    capitalMapper.insert(capital);
  }
 else {
    capitalMapper.updateBalance(transaction.getUserId(),transaction.getTokenId(),transaction.getNumber());
  }
}
Program: 69059
Project: 69059
Buggy source:
private void updateSold(BigInteger projectId,BigDecimal ethNumber,BigDecimal balance){
  Orders orders=new Orders();
  orders.setUserId(getUserId());
  orders.setProjectId(projectId);
  Integer orderNum=orderMapper.selectCount(orders);
  Integer buyerNum=orderNum == 0 ? 1 : 0;
  ProjectSold projectSold=new ProjectSold();
  projectSold.setId(projectId);
  projectSold.setSoldEth(ethNumber);
  projectSold.setBuyerNum(buyerNum);
  projectMapper.updateSoldBalance(projectSold);
}

Fixed version (ground truth):
private void updateSold(BigInteger projectId,BigDecimal ethNumber,BigDecimal balance){
  Orders orders=new Orders();
  orders.setUserId(getUserId());
  orders.setProjectId(projectId);
  Integer orderNum=orderMapper.selectCount(orders);
  Integer buyerNum=orderNum == 1 ? 1 : 0;
  ProjectSold projectSold=new ProjectSold();
  projectSold.setId(projectId);
  projectSold.setSoldEth(ethNumber);
  projectSold.setBuyerNum(buyerNum);
  projectMapper.updateSoldBalance(projectSold);
}
Program: 69060
Project: 69060
Buggy source:
private void addressHandler(org.web3j.protocol.core.methods.response.Transaction tx){
  String to=Web3jUtil.getTo(tx);
  String key=RedisConstants.LISTEN_ETH_ADDR + "String_Node_Str" + to;
  String hash=tx.getHash();
  BigInteger userId=(BigInteger)redisTemplate.opsForValue().get(key);
  if (null == userId) {
    return;
  }
  if (existHash(hash)) {
    return;
  }
  BigInteger tokenId=getTokenId(tx);
  Config config=configService.get(tokenId);
  if (null == config) {
    return;
  }
  Transaction transaction=new Transaction();
  transaction.setHash(hash);
  transaction.setUserId(userId);
  transaction.setTokenId(tokenId);
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_RECHARGE));
  transaction.setType(CommonConstants.RECHARGE);
  transaction.setStatus(CommonConstants.STATUS_SUCCESS);
  transaction.setToAddress(to);
  transaction.setFromAddress(tx.getFrom());
  transaction.setNumber(Web3jUtil.getValue(tx.getValue(),transaction.getTokenId(),redisTemplate));
  transaction.setPoundage(0f);
  transaction.setRealNumber(transaction.getNumber());
  transactionMapper.insertSelective(transaction);
  capitalMapper.updateBalance(transaction.getUserId(),transaction.getTokenId(),transaction.getNumber());
  this.transferBalance(transaction);
}

Fixed version (ground truth):
private void addressHandler(org.web3j.protocol.core.methods.response.Transaction tx){
  String to=Web3jUtil.getTo(tx);
  String key=RedisConstants.LISTEN_ETH_ADDR + "String_Node_Str" + to;
  String hash=tx.getHash();
  BigInteger userId=(BigInteger)redisTemplate.opsForValue().get(key);
  if (null == userId) {
    return;
  }
  if (existHash(hash)) {
    return;
  }
  BigInteger tokenId=getTokenId(tx);
  Config config=configService.get(tokenId);
  if (null == config) {
    return;
  }
  Transaction transaction=new Transaction();
  transaction.setHash(hash);
  transaction.setUserId(userId);
  transaction.setTokenId(tokenId);
  transaction.setOrderId(getOrderId(CommonConstants.ORDER_RECHARGE));
  transaction.setType(CommonConstants.RECHARGE);
  transaction.setStatus(CommonConstants.STATUS_SUCCESS);
  transaction.setToAddress(to);
  transaction.setFromAddress(tx.getFrom());
  transaction.setNumber(Web3jUtil.getValue(tx.getValue(),transaction.getTokenId(),redisTemplate));
  transaction.setPoundage(0f);
  transaction.setRealNumber(transaction.getNumber());
  transactionMapper.insertSelective(transaction);
  updateBalance(transaction);
  this.transferBalance(transaction);
}
Program: 69061
Project: 69061
Buggy source:
@Async public void transferBalance(Transaction transaction){
  try {
    EthGetBalance result=web3j.ethGetBalance(transaction.getToAddress(),DefaultBlockParameterName.LATEST).send();
    BigInteger needBalance=TransactionService.DEFAULT_GAS_LIMIT.multiply(TransactionService.DEFAULT_GAS_PRICE);
    BigInteger sendBalance=result.getBalance().subtract(needBalance);
    if (sendGasIfNull(transaction,result,needBalance)) {
      return;
    }
    String contractAddress=getContractAddressByTokenId(transaction);
    if (!transaction.getTokenId().equals(0)) {
      sendBalance=contractService.balanceOf(contractAddress,transaction.getToAddress());
    }
    sendTransaction(transaction.getToAddress(),defaultUser,contractAddress,sendBalance,false);
  }
 catch (  Exception e) {
    log.error(e.getMessage());
  }
}

Fixed version (ground truth):
@Async public void transferBalance(Transaction transaction){
  try {
    EthGetBalance result=web3j.ethGetBalance(transaction.getToAddress(),DefaultBlockParameterName.LATEST).send();
    BigInteger needBalance=TransactionService.DEFAULT_GAS_LIMIT.multiply(TransactionService.DEFAULT_GAS_PRICE);
    BigInteger sendBalance=result.getBalance().subtract(needBalance);
    if (sendGasIfNull(transaction,result,needBalance)) {
      return;
    }
    String contractAddress=getContractAddressByTokenId(transaction);
    if (!transaction.getTokenId().equals(0)) {
      sendBalance=contractService.balanceOf(contractAddress,transaction.getToAddress());
    }
    sendTransaction(transaction.getToAddress(),defaultUser,contractAddress,sendBalance,false);
  }
 catch (  Exception e) {
    e.printStackTrace();
    log.error(e.getMessage());
  }
}
Program: 69062
Project: 69062
Buggy source:
public void buy(BuyDTO buyDTO){
  Account account=accountService.getAccount(getUserId());
  Assert.isTrue(encoder.matches(buyDTO.getTransactionPassword(),account.getPassword()),MessageConstants.TRANSFER_PWD_ERR);
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,CommonConstants.PROJECT_NOT_EXIST);
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) < 0,MessageConstants.ETH_OVER);
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,CommonConstants.ETH_NOT_ENOUGH);
  addOrder(buyDTO,balance);
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
  String key=RedisConstants.USER_PROJECTS + "String_Node_Str" + getUserId();
  redisTemplate.opsForValue().set(key,orderMapper.getUserProject(getUserId()));
}

Fixed version (ground truth):
public void buy(BuyDTO buyDTO){
  Account account=accountService.getAccount(getUserId());
  Assert.isTrue(encoder.matches(buyDTO.getTransactionPassword(),account.getTransactionPassword()),MessageConstants.TRANSFER_PWD_ERR);
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,CommonConstants.PROJECT_NOT_EXIST);
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) < 0,MessageConstants.ETH_OVER);
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,CommonConstants.ETH_NOT_ENOUGH);
  addOrder(buyDTO,balance);
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
  String key=RedisConstants.USER_PROJECTS + "String_Node_Str" + getUserId();
  redisTemplate.opsForValue().set(key,orderMapper.getUserProject(getUserId()));
}
Program: 69063
Project: 69063
Buggy source:
public void buy(BuyDTO buyDTO){
  Account account=accountService.getAccount(getUserId());
  Assert.isTrue(encoder.matches(buyDTO.getTransactionPassword(),account.getTransactionPassword()),MessageConstants.TRANSFER_PWD_ERR);
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,CommonConstants.PROJECT_NOT_EXIST);
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) < 0,MessageConstants.ETH_OVER);
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,CommonConstants.ETH_NOT_ENOUGH);
  addOrder(buyDTO,balance);
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
  String key=RedisConstants.USER_PROJECTS + "String_Node_Str" + getUserId();
  redisTemplate.opsForValue().set(key,orderMapper.getUserProject(getUserId()));
}

Fixed version (ground truth):
public void buy(BuyDTO buyDTO){
  Account account=accountService.getAccount(getUserId());
  Assert.isTrue(encoder.matches(buyDTO.getTransactionPassword(),account.getTransactionPassword()),MessageConstants.TRANSFER_PWD_ERR);
  ProjectVO project=get(buyDTO.getProjectId());
  Assert.notNull(project,CommonConstants.PROJECT_NOT_EXIST);
  BigDecimal sold=getSold(buyDTO.getProjectId()).getSoldEth();
  Assert.isTrue(sold.add(buyDTO.getEthNumber()).compareTo(project.getEthNumber()) <= 0,MessageConstants.ETH_OVER);
  BigDecimal balance=buyDTO.getEthNumber().multiply(new BigDecimal(project.getRatio()));
  Capital ethCapital=new Capital();
  ethCapital.setUserId(getUserId());
  ethCapital.setTokenId(BigInteger.ZERO);
  Integer result=capitalMapper.updateEth(getUserId(),buyDTO.getEthNumber());
  Assert.isTrue(result > 0,CommonConstants.ETH_NOT_ENOUGH);
  addOrder(buyDTO,balance);
  Integer orderNum=account.getOrderNum();
  orderNum=null == orderNum ? 1 : ++orderNum;
  account.setOrderNum(orderNum);
  accountService.update(account);
  String key=RedisConstants.USER_PROJECTS + "String_Node_Str" + getUserId();
  redisTemplate.opsForValue().set(key,orderMapper.getUserProject(getUserId()));
}