mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
optimize code
This commit is contained in:
parent
8fa763f7d6
commit
fa588d65c8
@ -47,20 +47,17 @@ public class SeataHandlerInterceptor implements HandlerInterceptor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||||
Object handler) {
|
Object handler) {
|
||||||
Object xidStatus = request.getAttribute(BIND_XID);
|
String xid = RootContext.getXID();
|
||||||
if (null == xidStatus || !(boolean)xidStatus) {
|
String rpcXid = request.getHeader(RootContext.KEY_XID);
|
||||||
String xid = RootContext.getXID();
|
if (log.isDebugEnabled()) {
|
||||||
String rpcXid = request.getHeader(RootContext.KEY_XID);
|
log.debug("xid in RootContext {} xid in RpcContext {}", xid, rpcXid);
|
||||||
if (log.isDebugEnabled()) {
|
}
|
||||||
log.debug("xid in RootContext {} xid in RpcContext {}", xid, rpcXid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xid == null && rpcXid != null) {
|
if (xid == null && rpcXid != null) {
|
||||||
RootContext.bind(rpcXid);
|
RootContext.bind(rpcXid);
|
||||||
request.setAttribute(BIND_XID, true);
|
request.setAttribute(BIND_XID, true);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("bind {} to RootContext", rpcXid);
|
log.debug("bind {} to RootContext", rpcXid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -86,7 +83,6 @@ public class SeataHandlerInterceptor implements HandlerInterceptor {
|
|||||||
log.warn("xid in change during RPC from {} to {}", rpcXid, unbindXid);
|
log.warn("xid in change during RPC from {} to {}", rpcXid, unbindXid);
|
||||||
if (unbindXid != null) {
|
if (unbindXid != null) {
|
||||||
RootContext.bind(unbindXid);
|
RootContext.bind(unbindXid);
|
||||||
request.setAttribute(UNBIND_XID, true);
|
|
||||||
log.warn("bind {} back to RootContext", unbindXid);
|
log.warn("bind {} back to RootContext", unbindXid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user