-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: can't integrate dubbo with spring #6015
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 2.x #6015 +/- ##
=========================================
Coverage 49.57% 49.58%
- Complexity 4747 4751 +4
=========================================
Files 907 907
Lines 31275 31284 +9
Branches 3770 3770
=========================================
+ Hits 15506 15513 +7
- Misses 14238 14244 +6
+ Partials 1531 1527 -4
|
spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java
Outdated
Show resolved
Hide resolved
spring/src/main/java/io/seata/spring/remoting/parser/RemotingFactoryBeanParser.java
Outdated
Show resolved
Hide resolved
tcc/src/main/java/io/seata/rm/tcc/interceptor/parser/TccActionInterceptorParser.java
Outdated
Show resolved
Hide resolved
integration-tx-api/src/main/java/io/seata/integration/tx/api/util/ProxyUtil.java
Outdated
Show resolved
Hide resolved
...api/src/main/java/io/seata/integration/tx/api/interceptor/parser/DefaultInterfaceParser.java
Outdated
Show resolved
Hide resolved
...ava/io/seata/integration/tx/api/interceptor/parser/GlobalTransactionalInterceptorParser.java
Outdated
Show resolved
Hide resolved
spring/src/main/java/io/seata/spring/remoting/parser/RemotingFactoryBeanParser.java
Outdated
Show resolved
Hide resolved
RemotingFactoryBeanParser的一些问题讨论 |
使用第一种方案目前能规避spring集成的这个问题, 但是之后可能其他的实现也会有类似的需求, 那就需要开发者时刻注意到这个问题 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.RemotingFactoryBeanParser 删除它的spi加载,改为在GlobalTransactionScanner#setApplicationContext中创建并赋值
2.DefaultRemotingParser增加addRemotingParser方法,将RemotingFactoryBeanParser放入allRemotingParsers
3.RemotingFactoryBeanParser#isReference中的 DefaultRemotingParser.get().isReference(bean, beanName); 改为 DefaultRemotingParser.get().isReference(factoryBean, factoryBeanName); 进行测试,是否会出现死循环,如果会则要进行接下来第四点的改造
4. RemotingFactoryBeanParser实例化的时候通过spi将其它4种实现加载,去除直接使用DefaultRemotingParser.get().isReference/isService方法,而是直接遍历4种实现的isReference/isService
import io.seata.integration.tx.api.remoting.RemotingDesc; | ||
import io.seata.integration.tx.api.remoting.parser.AbstractedRemotingParser; | ||
import io.seata.integration.tx.api.remoting.parser.DefaultRemotingParser; | ||
import io.seata.spring.util.SpringProxyUtils; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
import java.util.Collections; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introducing java-related packages should be placed at the top
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -22,7 +22,7 @@ | |||
*/ | |||
public interface InterfaceParser { | |||
|
|||
ProxyInvocationHandler parserInterfaceToProxy(Object target) throws Exception; | |||
ProxyInvocationHandler parserInterfaceToProxy(Object target, String beanName) throws Exception; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.x 目前和spring解耦的,beanName是spring的定义。我们这里设置成objectName是不是更好,在spring的场景下:objectName = beanName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* register custom remoting parser | ||
* @param remotingParser | ||
*/ | ||
public void registerRemotingParser(RemotingParser remotingParser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注册方法最好加锁(因为可以牵扯到并发注册),或者使用copyOnwrite的方式
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -36,7 +40,7 @@ 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们是不是在构造方法里面加一个applicationContext!=null的check(防止一些spring异常场景,applicationContext没set进去),那么getRemotingFactoryBean里面的applicationContext!=null是可以去除掉的。
另外factoryBeanName的构建落在多个方法里面,是否能够抽出一个统一的方法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GLTM
LGTM |
Ⅰ. Describe what this PR did
fix(#6014)
Ⅱ. Does this pull request fix one issue?
fixes #6014
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews