Exception异常

public synchronized Throwable fillInStackTrace() {
        if (stackTrace != null ||
            backtrace != null /* Out of protocol state */ ) {
            fillInStackTrace(0);
            stackTrace = UNASSIGNED_STACK;
        }
        return this;
    }



public void setStackTrace(StackTraceElement[] stackTrace) {
        // Validate argument
        StackTraceElement[] defensiveCopy = stackTrace.clone();
        for (int i = 0; i < defensiv发eCopy.length; i++) {
            if (defensiveCopy[i] == null)
                throw new NullPointerException("stackTrace[" + i + "]");
        }

        synchronized (this) {
            if (this.stackTrace == null && // Immutable stack
                backtrace == null) // Test for out of protocol state
                return;
            this.stackTrace = defensiveCopy;
        }
    }


方法上加锁与代码块处理同步机制

lock 同步锁机制

异常处理  运行时异常与错误异常

private Lock lock = new ReentrantLock();
@Override
@Transactional(propagation = Propagation.REQUIRED)
public TtyResponse transferPayMoney(String orderId) throws TtyException {
HashMap<String, Object> params = new HashMap<String, Object>();
this.payCheck(orderId, params);

try{
lock.lock();
TtyResponse resp = this.queryPaymentType(params);
if(StringUtils.equals(RESP_CODE_FAIL, resp.getCode())
|| StringUtils.equals(RESP_CODE_WAYPAY, resp.getCode())){

resp = this.payMoney(params);
if(StringUtils.equals(this.RESP_CODE_FAIL, resp.getCode())){
this.updatePayTypeStatus(params, OrderStatus.CLOSED);
this.cancelTransfer(params);
} else if(StringUtils.equals(this.RESP_CODE_PROCESSING, resp.getCode())){

this.updateOrderStatus(params, OrderStatus.PROCESSING);
}
} else if(StringUtils.equals(RESP_CODE_PROCESSING, resp.getCode())){
return (new TtyResponse()).setCode(ITransferPayMoneyService.RESP_CODE_PROCESSING);

} else if(StringUtils.equals(RESP_CODE_SUCCESS, resp.getCode())){
this.transferSuccess(params);
return (new TtyResponse()).setCode(ITransferPayMoneyService.RESP_CODE_SUCCESS);
}
} finally{

lock.unlock();
}
return new TtyResponse();
}

你可能感兴趣的:(Exception异常)