feature: unify Jackson/fastjson serialization.
- [x] I have read the CONTRIBUTING.md guidelines.
- [x] I have registered the PR changes.
Ⅰ. Describe what this PR did
unify Jackson/fastjson serialization
Modules involved:
API interface:
classDiagram
class JsonSerializer {
<<interface>>
+String toJSONString(Object object)
+T parseObject(String text, Class~T~ clazz)
+T parseObject(String text, Type type)
}
class JsonUtil {
-JsonSerializer serializer
+JsonUtil(JsonSerializer serializer)
+String toJSONString(Object object)
+T parseObject(String text, Class~T~ clazz)
+T parseObject(String text, Type type)
+JsonSerializer getSerializer()
}
class JsonSerializerFactory {
<<static>>
+JsonSerializer getSerializer(String name)
}
class FastjsonJsonSerializer {
+String toJSONString(Object object)
+T parseObject(String text, Class~T~ clazz)
+T parseObject(String text, Type type)
+String toJSONString(Object object, boolean prettyPrint)
+String toJSONString(Object object, boolean ignoreAutoType, boolean prettyPrint)
+T parseObject(String text, Class~T~ type, boolean ignoreAutoType)
+boolean useAutoType(String json)
}
class JacksonJsonSerializer {
+String toJSONString(Object object)
+T parseObject(String text, Class~T~ clazz)
+T parseObject(String text, Type type)
+String toJSONString(Object object, boolean prettyPrint)
+String toJSONString(Object object, boolean ignoreAutoType, boolean prettyPrint)
+T parseObject(String text, Class~T~ type, boolean ignoreAutoType)
+boolean useAutoType(String json)
}
class GsonJsonSerializer {
+String toJSONString(Object object)
+T parseObject(String text, Class~T~ clazz)
+T parseObject(String text, Type type)
+String toJSONString(Object object, boolean prettyPrint)
+String toJSONString(Object object, boolean ignoreAutoType, boolean prettyPrint)
+T parseObject(String text, Class~T~ type, boolean ignoreAutoType)
+boolean useAutoType(String json)
}
JsonUtil --> JsonSerializer : uses
JsonSerializerFactory --> JsonSerializer : creates
FastjsonJsonSerializer ..|> JsonSerializer : implements
JacksonJsonSerializer ..|> JsonSerializer : implements
GsonJsonSerializer ..|> JsonSerializer : implements
Use flowcharts:
Ⅱ. Does this pull request fix one issue?
fixes #7554
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
Codecov Report
:x: Patch coverage is 77.97619% with 37 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 71.06%. Comparing base (b27e6be) to head (a9589ad).
Additional details and impacted files
@@ Coverage Diff @@
## 2.x #7760 +/- ##
============================================
+ Coverage 71.03% 71.06% +0.02%
Complexity 797 797
============================================
Files 1294 1299 +5
Lines 49528 49672 +144
Branches 5873 5884 +11
============================================
+ Hits 35182 35299 +117
- Misses 11437 11466 +29
+ Partials 2909 2907 -2
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...egration/tx/api/interceptor/ActionContextUtil.java | 56.36% <ø> (ø) |
|
| ...n/tx/api/interceptor/ActionInterceptorHandler.java | 74.25% <ø> (ø) |
|
| ...he/seata/rm/tcc/api/BusinessActionContextUtil.java | 40.00% <ø> (ø) |
|
| ...pache/seata/common/json/JsonSerializerFactory.java | 100.00% <100.00%> (ø) |
|
| ...tatelang/parser/utils/DesignerJsonTransformer.java | 67.27% <100.00%> (ø) |
|
| .../apache/seata/rm/datasource/ConnectionContext.java | 76.56% <66.66%> (ø) |
|
| ...in/java/org/apache/seata/common/json/JsonUtil.java | 80.00% <80.00%> (ø) |
|
| .../engine/invoker/impl/SpringBeanServiceInvoker.java | 67.97% <66.66%> (ø) |
|
| .../seata/common/json/impl/JacksonJsonSerializer.java | 94.64% <94.64%> (ø) |
|
| .../statelang/parser/impl/StateMachineParserImpl.java | 70.49% <40.00%> (ø) |
|
| ... and 3 more |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Are you developing based on an old branch? It would be better to use a new branch next time; otherwise, there will be many commits that don't belong to this pull request, which is detrimental to CR
Are you developing based on an old branch? It would be better to use a new branch next time; otherwise, there will be many commits that don't belong to this pull request, which is detrimental to CR您是否基于旧分支进行开发?下次最好使用一个新的分支;否则,将有许多提交不属于这个pull请求,这对CR是有害的
Yes, sorry, I forgot to reset when I created the new branch earlier, so there are some unnecessary commits : (
I’d really appreciate any feedback or suggestions from the community. orz I’m currently working on improving test coverage for this patch, and if all goes well, I plan to gradually replace the existing JsonUtil usages in other modules as well :)