Program: 35027
Project: 35027
Buggy source:
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value="String_Node_Str",notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=String.class)}) public Result stopAgent(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) StopAgentForm form) throws NulsException, IOException {
  AssertUtil.canNotEmpty(form);
  AssertUtil.canNotEmpty(form.getAddress());
  if (!AddressTool.validAddress(form.getAddress())) {
    throw new NulsRuntimeException(KernelErrorCode.PARAMETER_ERROR);
  }
  Account account=accountService.getAccount(form.getAddress()).getData();
  if (null == account) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  if (account.isEncrypted()) {
    AssertUtil.canNotEmpty(form.getPassword());
    try {
      if (!account.decrypt(form.getPassword())) {
        return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
      }
    }
 catch (    NulsException e) {
      return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
    }
  }
  StopAgentTransaction tx=new StopAgentTransaction();
  StopAgent stopAgent=new StopAgent();
  stopAgent.setAddress(AddressTool.getAddress(form.getAddress()));
  List<Agent> agentList=PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  Agent agent=null;
  for (  Agent a : agentList) {
    if (Arrays.equals(a.getAgentAddress(),account.getAddress().getBase58Bytes())) {
      agent=a;
      break;
    }
  }
  if (agent == null || agent.getDelHeight() > 0) {
    return Result.getFailed("String_Node_Str");
  }
  NulsDigestData createTxHash=agent.getTxHash();
  stopAgent.setCreateTxHash(createTxHash);
  tx.setTxData(stopAgent);
  CoinData coinData=new CoinData();
  List<Coin> toList=new ArrayList<>();
  toList.add(new Coin(stopAgent.getAddress(),agent.getDeposit(),0));
  coinData.setTo(toList);
  CreateAgentTransaction transaction=(CreateAgentTransaction)ledgerService.getTx(createTxHash);
  if (null == transaction) {
    return Result.getFailed("String_Node_Str");
  }
  List<Coin> fromList=new ArrayList<>();
  for (int index=0; index < transaction.getCoinData().getTo().size(); index++) {
    Coin coin=transaction.getCoinData().getTo().get(index);
    if (coin.getLockTime() == -1L && coin.getNa().equals(agent.getDeposit())) {
      coin.setOwner(ArraysTool.joinintTogether(transaction.getHash().serialize(),new VarInt(index).encode()));
      fromList.add(coin);
      break;
    }
  }
  if (fromList.isEmpty()) {
    return Result.getFailed(KernelErrorCode.DATA_ERROR);
  }
  coinData.setFrom(fromList);
  Na fee=TransactionFeeCalculator.getFee(tx.size());
  coinData.getTo().get(0).setNa(coinData.getTo().get(0).getNa().subtract(fee));
  tx.setCoinData(coinData);
  Result result1=this.txProcessing(tx,null,account,form.getPassword());
  if (result1.isFailed()) {
    return result1;
  }
  return Result.getSuccess().setData(tx.getHash().getDigestHex());
}

Fixed version (ground truth):
@POST @Path("String_Node_Str") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value="String_Node_Str",notes="String_Node_Str") @ApiResponses(value={@ApiResponse(code=200,message="String_Node_Str",response=String.class)}) public Result stopAgent(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) StopAgentForm form) throws NulsException, IOException {
  AssertUtil.canNotEmpty(form);
  AssertUtil.canNotEmpty(form.getAddress());
  if (!AddressTool.validAddress(form.getAddress())) {
    throw new NulsRuntimeException(KernelErrorCode.PARAMETER_ERROR);
  }
  Account account=accountService.getAccount(form.getAddress()).getData();
  if (null == account) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  if (account.isEncrypted() && account.isLocked()) {
    AssertUtil.canNotEmpty(form.getPassword());
    try {
      if (!account.decrypt(form.getPassword())) {
        return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
      }
    }
 catch (    NulsException e) {
      return Result.getFailed(AccountErrorCode.PASSWORD_IS_WRONG);
    }
  }
  StopAgentTransaction tx=new StopAgentTransaction();
  StopAgent stopAgent=new StopAgent();
  stopAgent.setAddress(AddressTool.getAddress(form.getAddress()));
  List<Agent> agentList=PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  Agent agent=null;
  for (  Agent a : agentList) {
    if (Arrays.equals(a.getAgentAddress(),account.getAddress().getBase58Bytes())) {
      agent=a;
      break;
    }
  }
  if (agent == null || agent.getDelHeight() > 0) {
    return Result.getFailed("String_Node_Str");
  }
  NulsDigestData createTxHash=agent.getTxHash();
  stopAgent.setCreateTxHash(createTxHash);
  tx.setTxData(stopAgent);
  CoinData coinData=new CoinData();
  List<Coin> toList=new ArrayList<>();
  toList.add(new Coin(stopAgent.getAddress(),agent.getDeposit(),0));
  coinData.setTo(toList);
  CreateAgentTransaction transaction=(CreateAgentTransaction)ledgerService.getTx(createTxHash);
  if (null == transaction) {
    return Result.getFailed("String_Node_Str");
  }
  List<Coin> fromList=new ArrayList<>();
  for (int index=0; index < transaction.getCoinData().getTo().size(); index++) {
    Coin coin=transaction.getCoinData().getTo().get(index);
    if (coin.getLockTime() == -1L && coin.getNa().equals(agent.getDeposit())) {
      coin.setOwner(ArraysTool.joinintTogether(transaction.getHash().serialize(),new VarInt(index).encode()));
      fromList.add(coin);
      break;
    }
  }
  if (fromList.isEmpty()) {
    return Result.getFailed(KernelErrorCode.DATA_ERROR);
  }
  coinData.setFrom(fromList);
  Na fee=TransactionFeeCalculator.getFee(tx.size());
  coinData.getTo().get(0).setNa(coinData.getTo().get(0).getNa().subtract(fee));
  tx.setCoinData(coinData);
  Result result1=this.txProcessing(tx,null,account,form.getPassword());
  if (result1.isFailed()) {
    return result1;
  }
  return Result.getSuccess().setData(tx.getHash().getDigestHex());
}