Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
wt-better committed Nov 14, 2023
2 parents a3d16ab + 6affce3 commit 1c674cf
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 29 deletions.
2 changes: 2 additions & 0 deletions changes/en-us/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The version is updated as follows:
- [[#5887](https://github.com/seata/seata/pull/5887)] fix global transaction hook repeat execute
- [[#6018](https://github.com/seata/seata/pull/6018)] fix incorrect metric report
- [[#6024](https://github.com/seata/seata/pull/6024)] fix the white screen after click the "View Global Lock" button on the transaction info page in the console
- [[#6015](https://github.com/seata/seata/pull/6015)] fix can't integrate dubbo with spring

### optimize:
- [[#5966](https://github.com/seata/seata/pull/5966)] decouple saga expression handling and remove evaluator package
Expand Down Expand Up @@ -220,6 +221,7 @@ Thanks to these contributors for their code commits. Please report an unintended
- [Aruato](https://github.com/Aruato)
- [ptyin](https://github.com/ptyin)
- [jsbxyyx](https://github.com/jsbxyyx)
- [xxxcrel](https://github.com/xxxcrel)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
Expand Down
2 changes: 2 additions & 0 deletions changes/zh-cn/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#5887](https://github.com/seata/seata/pull/5887)] 修复全局事务钩子重复执行
- [[#6018](https://github.com/seata/seata/pull/6018)] 修复错误的 metric 上报
- [[#6024](https://github.com/seata/seata/pull/6024)] 修复控制台点击事务信息页面中的"查看全局锁"按钮之后白屏的问题
- [[#6015](https://github.com/seata/seata/pull/6015)] 修复在spring环境下无法集成dubbo


### optimize:
Expand Down Expand Up @@ -222,6 +223,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [ggbocoder](https://github.com/ggbocoder)
- [ptyin](https://github.com/ptyin)
- [jsbxyyx](https://github.com/jsbxyyx)
- [xxxcrel](https://github.com/xxxcrel)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ protected void initInterfaceParser() {
}

@Override
public ProxyInvocationHandler parserInterfaceToProxy(Object target) throws Exception {
public ProxyInvocationHandler parserInterfaceToProxy(Object target, String objectName) throws Exception {
for (InterfaceParser interfaceParser : ALL_INTERFACE_PARSERS) {
ProxyInvocationHandler proxyInvocationHandler = interfaceParser.parserInterfaceToProxy(target);
ProxyInvocationHandler proxyInvocationHandler = interfaceParser.parserInterfaceToProxy(target, objectName);
if (proxyInvocationHandler != null) {
return proxyInvocationHandler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public class DefaultResourceRegisterParser {

protected static List<RegisterResourceParser> allRegisterResourceParsers = new ArrayList<>();

public void registerResource(Object target) {
public void registerResource(Object target, String beanName) {
for (RegisterResourceParser registerResourceParser : allRegisterResourceParsers) {
registerResourceParser.registerResource(target);
registerResourceParser.registerResource(target, beanName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GlobalTransactionalInterceptorParser implements InterfaceParser {
* @see GlobalLock // GlobalLock annotation
*/
@Override
public ProxyInvocationHandler parserInterfaceToProxy(Object target) throws Exception {
public ProxyInvocationHandler parserInterfaceToProxy(Object target, String objectName) throws Exception {
Class<?> serviceInterface = DefaultTargetClassParser.get().findTargetClass(target);
Class<?>[] interfacesIfJdk = DefaultTargetClassParser.get().findInterfaces(target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public interface InterfaceParser {

ProxyInvocationHandler parserInterfaceToProxy(Object target) throws Exception;
ProxyInvocationHandler parserInterfaceToProxy(Object target, String objectName) throws Exception;


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
*/
public interface RegisterResourceParser {

void registerResource(Object target);
void registerResource(Object target, String beanName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ protected void initRemotingParser() {
}
}

/**
* register custom remoting parser
* @param remotingParser
*/
public boolean registerRemotingParser(RemotingParser remotingParser) {
synchronized (this) {
return allRemotingParsers.add(remotingParser);
}
}

/**
* is remoting bean ?
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ public class ProxyUtil {
private static final Map<Object, Object> PROXYED_SET = new HashMap<>();

public static <T> T createProxy(T target) {
return createProxy(target, target.getClass().getName());
}

public static <T> T createProxy(T target, String beanName) {
try {
synchronized (PROXYED_SET) {
if (PROXYED_SET.containsKey(target)) {
return (T) PROXYED_SET.get(target);
}
ProxyInvocationHandler proxyInvocationHandler = DefaultInterfaceParser.get().parserInterfaceToProxy(target);
ProxyInvocationHandler proxyInvocationHandler = DefaultInterfaceParser.get().parserInterfaceToProxy(target, beanName);
if (proxyInvocationHandler == null) {
return target;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void parserInterfaceToProxy() throws Exception {
GlobalTransactionalInterceptorParser globalTransactionalInterceptorParser = new GlobalTransactionalInterceptorParser();

//when
ProxyInvocationHandler proxyInvocationHandler = globalTransactionalInterceptorParser.parserInterfaceToProxy(business);
ProxyInvocationHandler proxyInvocationHandler = globalTransactionalInterceptorParser.parserInterfaceToProxy(business, business.getClass().getName());

//then
Assertions.assertNotNull(proxyInvocationHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public void setTablePrefix(String tablePrefix) {
private static class StateMachineInstanceToStatementForInsert implements ObjectToStatement<StateMachineInstance> {
@Override
public void toStatement(StateMachineInstance stateMachineInstance,
PreparedStatement statement) throws SQLException {
PreparedStatement statement) throws SQLException {
statement.setString(1, stateMachineInstance.getId());
statement.setString(2, stateMachineInstance.getMachineId());
statement.setString(3, stateMachineInstance.getTenantId());
Expand All @@ -514,7 +514,7 @@ public void toStatement(StateMachineInstance stateMachineInstance,
private static class StateMachineInstanceToStatementForUpdate implements ObjectToStatement<StateMachineInstance> {
@Override
public void toStatement(StateMachineInstance stateMachineInstance,
PreparedStatement statement) throws SQLException {
PreparedStatement statement) throws SQLException {
statement.setTimestamp(1, new Timestamp(stateMachineInstance.getGmtEnd().getTime()));
statement.setBytes(2, stateMachineInstance.getSerializedException() != null ? (byte[]) stateMachineInstance.getSerializedException() : null);
statement.setObject(3, stateMachineInstance.getSerializedEndParams());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void reportTransactionFinished(StateMachineInstance machineInstance, Proc
try {
globalTransaction = getGlobalTransaction(machineInstance, context);
if (globalTransaction == null) {

throw new EngineExecutionException("Global transaction is not exists", FrameworkErrorCode.ObjectNotExists);
}

Expand Down Expand Up @@ -243,7 +242,6 @@ public void branchReport(StateInstance stateInstance, ProcessContext context) {
if (globalTransaction == null) {
throw new EngineExecutionException("Global transaction is not exists", FrameworkErrorCode.ObjectNotExists);
}

sagaTransactionalTemplate.branchReport(globalTransaction.getXid(), Long.parseLong(originalStateInst.getId()), branchStatus, null);
} catch (TransactionException e) {
LOGGER.error("Report branch status to server error: {}, StateMachine:{}, StateName:{}, XID: {}, branchId: {}, branchStatus:{}," + " Reason:{} ", e.getCode(), originalStateInst.getStateMachineInstance().getStateMachine().getName(), originalStateInst.getName(), originalStateInst.getStateMachineInstance().getId(), originalStateInst.getId(), branchStatus, e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
import io.seata.integration.tx.api.interceptor.handler.GlobalTransactionalInterceptorHandler;
import io.seata.integration.tx.api.interceptor.handler.ProxyInvocationHandler;
import io.seata.integration.tx.api.interceptor.parser.DefaultInterfaceParser;
import io.seata.integration.tx.api.remoting.parser.DefaultRemotingParser;
import io.seata.rm.RMClient;
import io.seata.spring.annotation.scannercheckers.PackageScannerChecker;
import io.seata.spring.remoting.parser.RemotingFactoryBeanParser;
import io.seata.spring.util.OrderUtil;
import io.seata.spring.util.SpringProxyUtils;
import io.seata.tm.TMClient;
Expand Down Expand Up @@ -279,7 +281,7 @@ protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey)
return bean;
}
interceptor = null;
ProxyInvocationHandler proxyInvocationHandler = DefaultInterfaceParser.get().parserInterfaceToProxy(bean);
ProxyInvocationHandler proxyInvocationHandler = DefaultInterfaceParser.get().parserInterfaceToProxy(bean, beanName);
if (proxyInvocationHandler == null) {
return bean;
}
Expand Down Expand Up @@ -472,6 +474,8 @@ public void afterPropertiesSet() {
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
RemotingFactoryBeanParser remotingFactoryBeanParser = new RemotingFactoryBeanParser(applicationContext);
DefaultRemotingParser.get().registerRemotingParser(remotingFactoryBeanParser);
this.setBeanFactory(applicationContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@
import io.seata.integration.tx.api.remoting.parser.DefaultRemotingParser;
import io.seata.spring.util.SpringProxyUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;

/**
* @author leezongjie
*/
public class RemotingFactoryBeanParser extends AbstractedRemotingParser {

public static ApplicationContext applicationContext;
public ApplicationContext applicationContext;

public RemotingFactoryBeanParser(ApplicationContext applicationContext) {
Assert.notNull(applicationContext, "applicationContext must not be null");
this.applicationContext = applicationContext;
}

/**
* if it is proxy bean, check if the FactoryBean is Remoting bean
Expand All @@ -36,14 +42,14 @@ public class RemotingFactoryBeanParser extends AbstractedRemotingParser {
* @param beanName the bean name
* @return boolean boolean
*/
protected static Object getRemotingFactoryBean(Object bean, String beanName) {
protected Object getRemotingFactoryBean(Object bean, String beanName) {
if (!SpringProxyUtils.isProxy(bean)) {
return null;
}
//the FactoryBean of proxy bean
String factoryBeanName = "&" + beanName;
String factoryBeanName = getFactoryBeanName(beanName);
Object factoryBean = null;
if (applicationContext != null && applicationContext.containsBean(factoryBeanName)) {
if (applicationContext.containsBean(factoryBeanName)) {
factoryBean = applicationContext.getBean(factoryBeanName);
}
return factoryBean;
Expand All @@ -55,7 +61,7 @@ public boolean isReference(Object bean, String beanName) {
if (factoryBean == null) {
return false;
}
return DefaultRemotingParser.get().isReference(bean, beanName);
return DefaultRemotingParser.get().isReference(factoryBean, getFactoryBeanName(beanName));
}

@Override
Expand All @@ -64,7 +70,7 @@ public boolean isService(Object bean, String beanName) {
if (factoryBean == null) {
return false;
}
return DefaultRemotingParser.get().isReference(bean, beanName);
return DefaultRemotingParser.get().isService(factoryBean, getFactoryBeanName(beanName));
}

@Override
Expand All @@ -73,12 +79,16 @@ public RemotingDesc getServiceDesc(Object bean, String beanName) throws Framewor
if (factoryBean == null) {
return null;
}
return DefaultRemotingParser.get().getServiceDesc(bean, beanName);
return DefaultRemotingParser.get().getServiceDesc(factoryBean, getFactoryBeanName(beanName));
}

private String getFactoryBeanName(String beanName) {
return "&" + beanName;
}

@Override
public short getProtocol() {
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void addTccAdvise(Object bean, String beanName, Field field, Class servic
RemotingDesc remotingDesc = new RemotingDesc();
remotingDesc.setServiceClass(serviceClass);

Object proxyBean = ProxyUtil.createProxy(bean);
Object proxyBean = ProxyUtil.createProxy(bean, beanName);
field.setAccessible(true);
field.set(bean, proxyBean);
LOGGER.info("Bean[" + bean.getClass().getName() + "] with name [" + field.getName() + "] would use proxy");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
public class TccActionInterceptorParser implements InterfaceParser {

@Override
public ProxyInvocationHandler parserInterfaceToProxy(Object target) {
boolean isTxRemotingBean = TxBeanParserUtils.isTxRemotingBean(target, target.toString());
public ProxyInvocationHandler parserInterfaceToProxy(Object target, String objectName) {
boolean isTxRemotingBean = TxBeanParserUtils.isTxRemotingBean(target, objectName);
if (isTxRemotingBean) {
RemotingDesc remotingDesc = DefaultRemotingParser.get().getRemotingBeanDesc(target);
if (remotingDesc != null) {
if (remotingDesc.isService()) {
DefaultResourceRegisterParser.get().registerResource(target);
DefaultResourceRegisterParser.get().registerResource(target, objectName);
}
if (remotingDesc.isReference()) {
//if it is a tcc remote reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
public class TccRegisterResourceParser implements RegisterResourceParser {

@Override
public void registerResource(Object target) {
boolean isTxRemotingBean = TxBeanParserUtils.isTxRemotingBean(target, target.toString());
public void registerResource(Object target, String beanName) {
boolean isTxRemotingBean = TxBeanParserUtils.isTxRemotingBean(target, beanName);
if (isTxRemotingBean) {
RemotingDesc remotingDesc = DefaultRemotingParser.get().getRemotingBeanDesc(target);
if (remotingDesc != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void parserInterfaceToProxy() {
NormalTccActionImpl tccAction = new NormalTccActionImpl();

//when
ProxyInvocationHandler proxyInvocationHandler = tccActionInterceptorParser.parserInterfaceToProxy(tccAction);
ProxyInvocationHandler proxyInvocationHandler = tccActionInterceptorParser.parserInterfaceToProxy(tccAction, tccAction.getClass().getName());

//then
Assertions.assertNotNull(proxyInvocationHandler);
Expand Down

0 comments on commit 1c674cf

Please sign in to comment.