Program: 35128
Project: 35128
Buggy source:
@Override public void approve(CoinData coinData,Transaction tx) throws NulsException {
  UtxoData utxoData=(UtxoData)coinData;
  for (  UtxoInput input : utxoData.getInputs()) {
    input.setTxHash(tx.getHash());
  }
  for (  UtxoOutput output : utxoData.getOutputs()) {
    output.setTxHash(tx.getHash());
  }
  List<UtxoOutput> unSpends=new ArrayList<>();
  Set<String> addressSet=new HashSet<>();
  try {
    lock.lock();
    for (int i=0; i < utxoData.getInputs().size(); i++) {
      UtxoInput input=utxoData.getInputs().get(i);
      UtxoOutput unSpend=ledgerCacheService.getUtxo(input.getKey());
      if (null == unSpend) {
        throw new NulsRuntimeException(ErrorCode.DATA_ERROR,"String_Node_Str");
      }
      if (!unSpend.isUsable()) {
        throw new NulsRuntimeException(ErrorCode.UTXO_UNUSABLE);
      }
      if (OutPutStatusEnum.UTXO_CONFIRM_UNSPEND == unSpend.getStatus()) {
        unSpend.setStatus(OutPutStatusEnum.UTXO_CONFIRM_SPEND);
      }
 else       if (OutPutStatusEnum.UTXO_UNCONFIRM_UNSPEND == unSpend.getStatus()) {
        unSpend.setStatus(OutPutStatusEnum.UTXO_UNCONFIRM_SPEND);
      }
      unSpends.add(unSpend);
      addressSet.add(unSpend.getAddress());
    }
    approveProcessOutput(utxoData.getOutputs(),tx,addressSet);
  }
 catch (  Exception e) {
    for (    UtxoOutput output : unSpends) {
      if (OutPutStatusEnum.UTXO_CONFIRM_SPEND.equals(output.getStatus())) {
        ledgerCacheService.updateUtxoStatus(output.getKey(),OutPutStatusEnum.UTXO_CONFIRM_UNSPEND,OutPutStatusEnum.UTXO_CONFIRM_SPEND);
      }
 else       if (OutPutStatusEnum.UTXO_UNCONFIRM_SPEND.equals(output.getStatus())) {
        ledgerCacheService.updateUtxoStatus(output.getKey(),OutPutStatusEnum.UTXO_UNCONFIRM_UNSPEND,OutPutStatusEnum.UTXO_UNCONFIRM_SPEND);
      }
    }
    for (int i=0; i < utxoData.getOutputs().size(); i++) {
      UtxoOutput output=utxoData.getOutputs().get(i);
      ledgerCacheService.removeUtxo(output.getKey());
    }
    throw e;
  }
 finally {
    lock.unlock();
    for (    String address : addressSet) {
      UtxoTransactionTool.getInstance().calcBalance(address,false);
    }
  }
}

Fixed version (ground truth):
@Override public void approve(CoinData coinData,Transaction tx) throws NulsException {
  UtxoData utxoData=(UtxoData)coinData;
  for (  UtxoInput input : utxoData.getInputs()) {
    input.setTxHash(tx.getHash());
  }
  for (  UtxoOutput output : utxoData.getOutputs()) {
    output.setTxHash(tx.getHash());
  }
  List<UtxoOutput> unSpends=new ArrayList<>();
  Set<String> addressSet=new HashSet<>();
  try {
    lock.lock();
    for (int i=0; i < utxoData.getInputs().size(); i++) {
      UtxoInput input=utxoData.getInputs().get(i);
      UtxoOutput unSpend=ledgerCacheService.getUtxo(input.getKey());
      if (null == unSpend) {
        throw new NulsRuntimeException(ErrorCode.DATA_ERROR,"String_Node_Str");
      }
      if (!unSpend.isUsable()) {
        throw new NulsRuntimeException(ErrorCode.UTXO_UNUSABLE);
      }
      if (OutPutStatusEnum.UTXO_CONFIRMED_UNSPENT == unSpend.getStatus()) {
        unSpend.setStatus(OutPutStatusEnum.UTXO_CONFIRMED_SPENT);
      }
 else       if (OutPutStatusEnum.UTXO_UNCONFIRMED_UNSPENT == unSpend.getStatus()) {
        unSpend.setStatus(OutPutStatusEnum.UTXO_UNCONFIRMED_SPENT);
      }
      unSpends.add(unSpend);
      addressSet.add(unSpend.getAddress());
    }
    approveProcessOutput(utxoData.getOutputs(),tx,addressSet);
  }
 catch (  Exception e) {
    for (    UtxoOutput output : unSpends) {
      if (OutPutStatusEnum.UTXO_CONFIRMED_SPENT.equals(output.getStatus())) {
        ledgerCacheService.updateUtxoStatus(output.getKey(),OutPutStatusEnum.UTXO_CONFIRMED_UNSPENT,OutPutStatusEnum.UTXO_CONFIRMED_SPENT);
      }
 else       if (OutPutStatusEnum.UTXO_UNCONFIRMED_SPENT.equals(output.getStatus())) {
        ledgerCacheService.updateUtxoStatus(output.getKey(),OutPutStatusEnum.UTXO_UNCONFIRMED_UNSPENT,OutPutStatusEnum.UTXO_UNCONFIRMED_SPENT);
      }
    }
    for (int i=0; i < utxoData.getOutputs().size(); i++) {
      UtxoOutput output=utxoData.getOutputs().get(i);
      ledgerCacheService.removeUtxo(output.getKey());
    }
    throw e;
  }
 finally {
    lock.unlock();
    for (    String address : addressSet) {
      UtxoTransactionTool.getInstance().calcBalance(address,false);
    }
  }
}