-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
optimize: Refactoring the code of TCC mode #3730
optimize: Refactoring the code of TCC mode #3730
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3730 +/- ##
=============================================
+ Coverage 40.84% 40.86% +0.02%
- Complexity 2945 2956 +11
=============================================
Files 663 662 -1
Lines 22260 22310 +50
Branches 2755 2777 +22
=============================================
+ Hits 9091 9116 +25
- Misses 12326 12347 +21
- Partials 843 847 +4
|
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
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.
LTGM for @tanzzj
tcc/src/main/java/io/seata/rm/tcc/api/BusinessActionContextParameter.java
Show resolved
Hide resolved
…法,auto set the updated为true,如果有变更过的话。
...toconfigure-client/src/main/resources/META-INF/additional-spring-configuration-metadata.json
Show resolved
Hide resolved
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
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
Ⅰ. Describe what this PR did
optimize: Refactoring the code of TCC mode.
优化:重构TCC模式相关的部分代码。
Ⅱ. Does this pull request fix one issue?
none
Ⅲ. Why don't you add test cases (unit test/integration test)?
none
Ⅳ. Describe how to verify it
Verify it by the unit test.
Ⅴ. Special notes for reviews
改造内容如下:
一、移除已不再使用的代码:
ActionInterceptorHandler.proceed(...)
方法,返回Map
没有什么意义,较老的代码了,现简化为直接返回business的result。对应的常量也删除掉。BusinessActivityContext
类。二、封装或转移部分代码并优化逻辑:
BusinessActionContextParameter
注解的配置读取参数值并存入context
” 的功能封装到ActionContextUtil.loadParamByAnnotationAndPutToContext(...)
方法中,供多处共同调用,减少重复代码。同时该工具方法的逻辑也进一步优化,避免一些不应该抛出的异常。
如:1)避免“使用index属性时,可能抛出的数组越界”的异常;
2)避免List类型强转失败的异常,只打印一个warn日志。
ActionContextUtil.getAllField
方法,转移到ReflectionUtil
工具类中,并优化添加了缓存功能。三、BUG修复:
TccActionInterceptor
中的一个NPE的BUG,虽然目前的应用不会命中这个BUG,但就该类的逻辑来说,是一个BUG。四、其他优化:
BusinessActionUtil.addContext
方法的逻辑优化,存入的数据转为JSON数据;同时添加方便二阶段获取该参数值
的方法(可自定义想要转换成的类型,而不再由seata自动转成Map
);BusinessActionContextParameter
中,添加value
属性,同义于paramName