Program: 34977
Project: 34977
Buggy source:
@GET @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 RpcClientResult getStopAgentFee(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) @QueryParam("String_Node_Str") String address) throws NulsException, IOException {
  AssertUtil.canNotEmpty(address,"String_Node_Str");
  if (!AddressTool.validAddress(address)) {
    return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult();
  }
  StopAgentTransaction tx=new StopAgentTransaction();
  StopAgent stopAgent=new StopAgent();
  stopAgent.setAddress(AddressTool.getAddress(address));
  List<Agent> agentList=PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  Agent agent=null;
  for (  Agent a : agentList) {
    if (a.getDelHeight() > 0) {
      continue;
    }
    if (Arrays.equals(a.getAgentAddress(),stopAgent.getAddress())) {
      agent=a;
      break;
    }
  }
  if (agent == null || agent.getDelHeight() > 0) {
    return Result.getFailed(PocConsensusErrorCode.AGENT_NOT_EXIST).toRpcClientResult();
  }
  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(KernelErrorCode.DATA_NOT_FOUND).toRpcClientResult();
  }
  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).toRpcClientResult();
  }
  coinData.setFrom(fromList);
  Na fee=TransactionFeeCalculator.getMaxFee(tx.size());
  coinData.getTo().get(0).setNa(coinData.getTo().get(0).getNa().subtract(fee));
  tx.setCoinData(coinData);
  Na resultFee=TransactionFeeCalculator.getMaxFee(tx.size() + P2PKHScriptSig.DEFAULT_SERIALIZE_LENGTH);
  Map<String,Object> valueMap=new HashMap<>();
  valueMap.put("String_Node_Str",resultFee.getValue());
  return Result.getSuccess().setData(valueMap).toRpcClientResult();
}

Fixed version (ground truth):
@GET @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 RpcClientResult getStopAgentFee(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) @QueryParam("String_Node_Str") String address) throws NulsException, IOException {
  AssertUtil.canNotEmpty(address,"String_Node_Str");
  if (!AddressTool.validAddress(address)) {
    return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult();
  }
  StopAgentTransaction tx=new StopAgentTransaction();
  StopAgent stopAgent=new StopAgent();
  stopAgent.setAddress(AddressTool.getAddress(address));
  List<Agent> agentList=PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  Agent agent=null;
  for (  Agent a : agentList) {
    if (a.getDelHeight() > 0) {
      continue;
    }
    if (Arrays.equals(a.getAgentAddress(),stopAgent.getAddress())) {
      agent=a;
      break;
    }
  }
  if (agent == null || agent.getDelHeight() > 0) {
    return Result.getFailed(PocConsensusErrorCode.AGENT_NOT_EXIST).toRpcClientResult();
  }
  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(KernelErrorCode.DATA_NOT_FOUND).toRpcClientResult();
  }
  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).toRpcClientResult();
  }
  coinData.setFrom(fromList);
  Na fee=TransactionFeeCalculator.getMaxFee(tx.size());
  coinData.getTo().get(0).setNa(coinData.getTo().get(0).getNa().subtract(fee));
  tx.setCoinData(coinData);
  Na resultFee=TransactionFeeCalculator.getMaxFee(tx.size() + P2PKHScriptSig.DEFAULT_SERIALIZE_LENGTH);
  return Result.getSuccess().setData(resultFee).toRpcClientResult();
}