Program: 35001
Project: 35001
Buggy source:
@Override public Result onCommit(RedPunishTransaction1 tx,Object secondaryData){
  RedPunishData punishData=tx.getTxData();
  BlockHeader header=(BlockHeader)secondaryData;
  BlockRoundData roundData=new BlockRoundData(header.getExtend());
  PunishLogPo punishLogPo=new PunishLogPo();
  punishLogPo.setAddress(punishData.getAddress());
  punishLogPo.setHeight(tx.getBlockHeight());
  punishLogPo.setRoundIndex(roundData.getRoundIndex());
  punishLogPo.setTime(tx.getTime());
  punishLogPo.setType(PunishType.RED.getCode());
  List<Agent> agentList=PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  Agent agent=null;
  for (  Agent agent_ : agentList) {
    if (agent_.getDelHeight() > 0) {
      continue;
    }
    if (Arrays.equals(agent_.getAgentAddress(),punishLogPo.getAddress())) {
      agent=agent_;
      break;
    }
  }
  if (null == agent) {
    Log.error("String_Node_Str");
    return Result.getSuccess();
  }
  CreateAgentTransaction transaction=(CreateAgentTransaction)this.ledgerService.getTx(agent.getTxHash());
  if (null == transaction) {
    return Result.getFailed(KernelErrorCode.DATA_ERROR,"String_Node_Str");
  }
  try {
    Result unlockResult=this.ledgerService.unlockTxCoinData(transaction,tx.getTime() + 60 * 24 * 3600000L);
    if (unlockResult.isFailed()) {
      return unlockResult;
    }
    unlockResult=this.accountLedgerService.unlockCoinData(transaction,tx.getTime() + 60 * 24 * 3600000L);
    if (unlockResult.isFailed()) {
      this.ledgerService.rollbackUnlockTxCoinData(transaction);
      return unlockResult;
    }
  }
 catch (  NulsException e) {
    Log.error(e);
    return Result.getFailed(e.getErrorCode(),e.getMessage());
  }
  List<DepositPo> depositPoList=depositStorageService.getList();
  if (null == depositPoList) {
    return Result.getSuccess();
  }
  List<Transaction> unlockedList=new ArrayList<>();
  unlockedList.add(transaction);
  for (  DepositPo po : depositPoList) {
    if (po.getDelHeight() >= 0) {
      continue;
    }
    if (!po.getAgentHash().equals(agent.getTxHash())) {
      continue;
    }
    po.setDelHeight(tx.getBlockHeight());
    Transaction depositTx=ledgerService.getTx(po.getTxHash());
    try {
      Result result=ledgerService.unlockTxCoinData(depositTx,0L);
      if (result.isFailed()) {
        this.rollbackUnlockTxList(unlockedList);
        return result;
      }
      result=accountLedgerService.unlockCoinData(depositTx,0L);
      if (result.isFailed()) {
        this.rollbackUnlockTxList(unlockedList);
        return result;
      }
      boolean b=depositStorageService.save(po);
      if (!b) {
        this.rollbackUnlockTxList(unlockedList);
        return ValidateResult.getFailedResult(this.getClass().getName(),"String_Node_Str");
      }
      unlockedList.add(depositTx);
    }
 catch (    NulsException e) {
      this.rollbackUnlockTxList(unlockedList);
      return Result.getFailed(e.getMessage());
    }
  }
  boolean success=storageService.save(punishLogPo);
  if (!success) {
    this.rollbackUnlockTxList(unlockedList);
    throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
  }
  AgentPo agentPo=PoConvertUtil.agentToPo(agent);
  agentPo.setDelHeight(tx.getBlockHeight());
  success=agentStorageService.save(agentPo);
  if (!success) {
    this.rollbackUnlockTxList(unlockedList);
    this.storageService.delete(punishLogPo.getKey());
    return Result.getFailed(KernelErrorCode.DATA_ERROR,"String_Node_Str");
  }
  return Result.getSuccess();
}

Fixed version (ground truth):
@Override public Result onCommit(RedPunishTransaction tx,Object secondaryData){
  RedPunishData punishData=tx.getTxData();
  BlockHeader header=(BlockHeader)secondaryData;
  BlockRoundData roundData=new BlockRoundData(header.getExtend());
  PunishLogPo punishLogPo=new PunishLogPo();
  punishLogPo.setAddress(punishData.getAddress());
  punishLogPo.setHeight(tx.getBlockHeight());
  punishLogPo.setRoundIndex(roundData.getRoundIndex());
  punishLogPo.setTime(tx.getTime());
  punishLogPo.setType(PunishType.RED.getCode());
  List<Agent> agentList=PocConsensusContext.getChainManager().getMasterChain().getChain().getAgentList();
  Agent agent=null;
  for (  Agent agent_ : agentList) {
    if (agent_.getDelHeight() > 0) {
      continue;
    }
    if (Arrays.equals(agent_.getAgentAddress(),punishLogPo.getAddress())) {
      agent=agent_;
      break;
    }
  }
  if (null == agent) {
    Log.error("String_Node_Str");
    return Result.getSuccess();
  }
  CreateAgentTransaction transaction=(CreateAgentTransaction)this.ledgerService.getTx(agent.getTxHash());
  if (null == transaction) {
    return Result.getFailed(KernelErrorCode.DATA_ERROR,"String_Node_Str");
  }
  try {
    Result unlockResult=this.ledgerService.unlockTxCoinData(transaction,tx.getTime() + 60 * 24 * 3600000L);
    if (unlockResult.isFailed()) {
      return unlockResult;
    }
    unlockResult=this.accountLedgerService.unlockCoinData(transaction,tx.getTime() + 60 * 24 * 3600000L);
    if (unlockResult.isFailed()) {
      this.ledgerService.rollbackUnlockTxCoinData(transaction);
      return unlockResult;
    }
  }
 catch (  NulsException e) {
    Log.error(e);
    return Result.getFailed(e.getErrorCode(),e.getMessage());
  }
  List<DepositPo> depositPoList=depositStorageService.getList();
  if (null == depositPoList) {
    return Result.getSuccess();
  }
  List<Transaction> unlockedList=new ArrayList<>();
  unlockedList.add(transaction);
  for (  DepositPo po : depositPoList) {
    if (po.getDelHeight() >= 0) {
      continue;
    }
    if (!po.getAgentHash().equals(agent.getTxHash())) {
      continue;
    }
    po.setDelHeight(tx.getBlockHeight());
    Transaction depositTx=ledgerService.getTx(po.getTxHash());
    try {
      Result result=ledgerService.unlockTxCoinData(depositTx,0L);
      if (result.isFailed()) {
        this.rollbackUnlockTxList(unlockedList);
        return result;
      }
      result=accountLedgerService.unlockCoinData(depositTx,0L);
      if (result.isFailed()) {
        this.rollbackUnlockTxList(unlockedList);
        return result;
      }
      boolean b=depositStorageService.save(po);
      if (!b) {
        this.rollbackUnlockTxList(unlockedList);
        return ValidateResult.getFailedResult(this.getClass().getName(),"String_Node_Str");
      }
      unlockedList.add(depositTx);
    }
 catch (    NulsException e) {
      this.rollbackUnlockTxList(unlockedList);
      return Result.getFailed(e.getMessage());
    }
  }
  boolean success=storageService.save(punishLogPo);
  if (!success) {
    this.rollbackUnlockTxList(unlockedList);
    throw new NulsRuntimeException(KernelErrorCode.FAILED,"String_Node_Str");
  }
  AgentPo agentPo=PoConvertUtil.agentToPo(agent);
  agentPo.setDelHeight(tx.getBlockHeight());
  success=agentStorageService.save(agentPo);
  if (!success) {
    this.rollbackUnlockTxList(unlockedList);
    this.storageService.delete(punishLogPo.getKey());
    return Result.getFailed(KernelErrorCode.DATA_ERROR,"String_Node_Str");
  }
  return Result.getSuccess();
}