Skip to content

Commit

Permalink
bugfix: pass txId into TCC interceptor (apache#1278)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangthen authored and ujjboy committed Jul 8, 2019
1 parent 3e72c59 commit 0c5c6e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
*/
package io.seata.spring.tcc;

import java.lang.reflect.Method;
import java.util.Map;

import io.seata.common.Constants;
import io.seata.common.executor.Callback;
import io.seata.common.util.StringUtils;
import io.seata.core.context.RootContext;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
import io.seata.rm.tcc.interceptor.ActionInterceptorHandler;
Expand All @@ -32,6 +28,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;
import java.util.Map;

/**
* TCC Interceptor
*
Expand Down Expand Up @@ -83,7 +82,7 @@ public Object invoke(final MethodInvocation invocation) throws Throwable {
try {
Object[] methodArgs = invocation.getArguments();
//Handler the TCC Aspect
Map<String, Object> ret = actionInterceptorHandler.proceed(method, methodArgs, businessAction,
Map<String, Object> ret = actionInterceptorHandler.proceed(method, methodArgs, xid, businessAction,
new Callback<Object>() {
@Override
public Object execute() throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@
*/
package io.seata.rm.tcc.interceptor;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;

import io.seata.common.Constants;
import io.seata.common.exception.FrameworkException;
import io.seata.common.executor.Callback;
import io.seata.common.util.NetUtil;
import io.seata.core.context.RootContext;
import io.seata.core.model.BranchType;
import io.seata.rm.DefaultResourceManager;
import io.seata.rm.tcc.api.BusinessActionContext;
Expand All @@ -36,6 +28,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Handler the TCC Participant Aspect : Setting Context, Creating Branch Record
*
Expand All @@ -55,13 +53,12 @@ public class ActionInterceptorHandler {
* @return map map
* @throws Throwable the throwable
*/
public Map<String, Object> proceed(Method method, Object[] arguments, TwoPhaseBusinessAction businessAction,
public Map<String, Object> proceed(Method method, Object[] arguments, String xid, TwoPhaseBusinessAction businessAction,
Callback<Object> targetCallback) throws Throwable {
Map<String, Object> ret = new HashMap<String, Object>(16);

//TCC name
String actionName = businessAction.name();
String xid = RootContext.getXID();
BusinessActionContext actionContext = new BusinessActionContext();
actionContext.setXid(xid);
//set action anme
Expand Down

0 comments on commit 0c5c6e6

Please sign in to comment.