Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zw201913
Copy link
Contributor

@zw201913 zw201913 commented Feb 17, 2023

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #5011
fixes #5334

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@funky-eyes funky-eyes changed the title optimize:add jackson json parser and gson json parser for tcc business action context optimize: add jackson json parser and gson json parser for tcc business action context Feb 17, 2023
*/
public class JsonParserFactory {

private static Map<String, JsonParser> JSON_PARSER_INSTANCES = new ConcurrentHashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static final

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use ConcurrentHashMap ?

@funky-eyes funky-eyes added this to the 2.0.0 milestone Feb 17, 2023
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. mode: TCC TCC transaction mode module/tcc tcc module labels Feb 17, 2023
@zw201913 zw201913 changed the title optimize: add jackson json parser and gson json parser for tcc business action context feature: add jackson json parser and gson json parser for tcc business action context Feb 17, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 17, 2023

Codecov Report

Merging #5352 (164ae7f) into 2.x (1400743) will increase coverage by 0.19%.
The diff coverage is 0.00%.

❗ Current head 164ae7f differs from pull request most recent head 007bb40. Consider uploading reports for the commit 007bb40 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5352      +/-   ##
============================================
+ Coverage     48.54%   48.73%   +0.19%     
- Complexity     4300     4311      +11     
============================================
  Files           771      775       +4     
  Lines         27350    27372      +22     
  Branches       3410     3408       -2     
============================================
+ Hits          13277    13340      +63     
+ Misses        12669    12627      -42     
- Partials       1404     1405       +1     
Impacted Files Coverage Δ
...c/main/java/io/seata/common/ConfigurationKeys.java 0.00% <ø> (ø)
...ommon/src/main/java/io/seata/common/Constants.java 100.00% <ø> (ø)
...n/src/main/java/io/seata/common/DefaultValues.java 0.00% <ø> (ø)
.../io/seata/common/exception/JsonParseException.java 0.00% <0.00%> (ø)
...a/io/seata/integration/tx/api/json/JsonParser.java 0.00% <0.00%> (ø)
...ata/integration/tx/api/json/JsonParserFactory.java 0.00% <0.00%> (ø)
.../seata/integration/tx/api/json/JsonParserWrap.java 0.00% <0.00%> (ø)
...ava/io/seata/integration/tx/api/util/JsonUtil.java 0.00% <0.00%> (ø)
...main/java/io/seata/rm/tcc/json/FastJsonParser.java 50.00% <0.00%> (-16.67%) ⬇️
...main/java/io/seata/rm/tcc/json/GsonJsonParser.java 0.00% <0.00%> (ø)
... and 19 more

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

return this.mapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
LOGGER.error("jackson toJSONString exception, {}", e.getMessage(), e);
throw new RuntimeException(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 异常抛出了,就不要在日志里记录堆栈。会导致重复记录;
  2. 另外,单独加一个JSON解析异常类吧。多种JSON解析方式失败后,都抛出同一种异常。

if (Objects.isNull(text) || Objects.isNull(clazz)) {
return null;
}
String jsonParseName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here has a bug and may change to

String jsonParseName = text.startsWith(Constants.JACKSON_JSON_TEXT_PREFIX) ? 
  Constants.JACKSON_JSON_PARSER_NAME : CONFIG_JSON_PARSER_NAME;

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the configuration item into the configuration file.

Copy link
Contributor

@wangliang181230 wangliang181230 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wangliang181230 wangliang181230 merged commit 04a0b68 into apache:2.x Feb 20, 2023
@slievrly
Copy link
Member

LGTM

Support for Spring configuration is currently environment first, but should existing PropertiesBeans be consistent?

YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mode: TCC TCC transaction mode module/tcc tcc module type: feature Category issues or prs related to feature request.

Projects

None yet

6 participants