Program: 35029
Project: 35029
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<String> createAgent(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) CreateAgentForm form) throws NulsException {
  AssertUtil.canNotEmpty(form);
  AssertUtil.canNotEmpty(form.getAgentAddress());
  AssertUtil.canNotEmpty(form.getAgentName());
  AssertUtil.canNotEmpty(form.getPackingAddress());
  AssertUtil.canNotEmpty(form.getDeposit());
  AssertUtil.canNotEmpty(form.getRemark());
  if (!AddressTool.validAddress(form.getPackingAddress()) || !AddressTool.validAddress(form.getAgentAddress())) {
    throw new NulsRuntimeException(KernelErrorCode.PARAMETER_ERROR);
  }
  Account account=accountService.getAccount(form.getAgentAddress()).getData();
  if (null == account) {
    return Result.getFailed(AccountErrorCode.ACCOUNT_NOT_EXIST);
  }
  if (account.isEncrypted()) {
    AssertUtil.canNotEmpty(form.getPassword());
  }
  CreateAgentTransaction tx=new CreateAgentTransaction();
  tx.setTime(TimeService.currentTimeMillis());
  Agent agent=new Agent();
  agent.setAgentAddress(AddressTool.getAddress(form.getAgentAddress()));
  agent.setPackingAddress(AddressTool.getAddress(form.getPackingAddress()));
  if (StringUtils.isBlank(form.getRewardAddress())) {
    agent.setRewardAddress(agent.getAgentAddress());
  }
 else {
    agent.setRewardAddress(AddressTool.getAddress(form.getRewardAddress()));
  }
  try {
    agent.setAgentName(form.getAgentName().getBytes(NulsConfig.DEFAULT_ENCODING));
    agent.setIntroduction(form.getRemark().getBytes(NulsConfig.DEFAULT_ENCODING));
  }
 catch (  UnsupportedEncodingException e) {
    Log.error(e);
    return Result.getFailed(e.getMessage());
  }
  agent.setDeposit(Na.valueOf(form.getDeposit()));
  agent.setCommissionRate(form.getCommissionRate());
  tx.setTxData(agent);
  CoinData coinData=new CoinData();
  List<Coin> toList=new ArrayList<>();
  toList.add(new Coin(agent.getAgentAddress(),agent.getDeposit(),-1));
  coinData.setTo(toList);
  tx.setCoinData(coinData);
  CoinDataResult result=accountLedgerService.getCoinData(agent.getAgentAddress(),agent.getDeposit(),tx.size() + P2PKHScriptSig.DEFAULT_SERIALIZE_LENGTH);
  Result result1=this.txProcessing(tx,result,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<String> createAgent(@ApiParam(name="String_Node_Str",value="String_Node_Str",required=true) CreateAgentForm form) throws NulsException {
  AssertUtil.canNotEmpty(form);
  AssertUtil.canNotEmpty(form.getAgentAddress());
  AssertUtil.canNotEmpty(form.getAgentName());
  AssertUtil.canNotEmpty(form.getPackingAddress());
  AssertUtil.canNotEmpty(form.getDeposit());
  AssertUtil.canNotEmpty(form.getRemark());
  if (!AddressTool.validAddress(form.getPackingAddress()) || !AddressTool.validAddress(form.getAgentAddress())) {
    throw new NulsRuntimeException(KernelErrorCode.PARAMETER_ERROR);
  }
  Account account=accountService.getAccount(form.getAgentAddress()).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);
    }
  }
  CreateAgentTransaction tx=new CreateAgentTransaction();
  tx.setTime(TimeService.currentTimeMillis());
  Agent agent=new Agent();
  agent.setAgentAddress(AddressTool.getAddress(form.getAgentAddress()));
  agent.setPackingAddress(AddressTool.getAddress(form.getPackingAddress()));
  if (StringUtils.isBlank(form.getRewardAddress())) {
    agent.setRewardAddress(agent.getAgentAddress());
  }
 else {
    agent.setRewardAddress(AddressTool.getAddress(form.getRewardAddress()));
  }
  try {
    agent.setAgentName(form.getAgentName().getBytes(NulsConfig.DEFAULT_ENCODING));
    agent.setIntroduction(form.getRemark().getBytes(NulsConfig.DEFAULT_ENCODING));
  }
 catch (  UnsupportedEncodingException e) {
    Log.error(e);
    return Result.getFailed(e.getMessage());
  }
  agent.setDeposit(Na.valueOf(form.getDeposit()));
  agent.setCommissionRate(form.getCommissionRate());
  tx.setTxData(agent);
  CoinData coinData=new CoinData();
  List<Coin> toList=new ArrayList<>();
  toList.add(new Coin(agent.getAgentAddress(),agent.getDeposit(),-1));
  coinData.setTo(toList);
  tx.setCoinData(coinData);
  CoinDataResult result=accountLedgerService.getCoinData(agent.getAgentAddress(),agent.getDeposit(),tx.size() + P2PKHScriptSig.DEFAULT_SERIALIZE_LENGTH);
  Result result1=this.txProcessing(tx,result,account,form.getPassword());
  if (result1.isFailed()) {
    return result1;
  }
  return Result.getSuccess().setData(tx.getHash().getDigestHex());
}