Skip to content

Commit 098feb2

Browse files
authored
feat(docs):add json-common config docs (#1080)
1 parent 1324e6b commit 098feb2

4 files changed

Lines changed: 183 additions & 0 deletions

File tree

i18n/en/docusaurus-plugin-content-docs/current/ops/upgrade.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ description: Seata upgrade.
66

77
# Version Upgrade Guide
88

9+
<a href="#12" target="_self">12. What compatibility matters need to be paid attention to when upgrading to seata 2.7? </a>
10+
<br/>
11+
912
<a href="#11" target="_self">11. What compatibility matters need to be paid attention to when upgrading to seata 2.5? </a>
1013
<br/>
1114

@@ -39,6 +42,22 @@ description: Seata upgrade.
3942
<a href="#1" target="_self">1. How to upgrade versions 0.8 and 0.9 to version 1.0? </a>
4043
<br/>
4144

45+
------
46+
<h3 id='12'>12. What compatibility matters need to be paid attention to when upgrading to seata 2.7?</h3>
47+
<details>
48+
<summary><mark>Notes</mark></summary>
49+
50+
1. Seata 2.7 introduces a unified JSON module, `json-common`, to centralize internal JSON serialization, deserialization, and security control capabilities.
51+
2. The default JSON serializer is now `jackson`. If no JSON serializer is explicitly configured, `JsonUtil` resolves to `jackson`.
52+
3. The JSON serializer should be switched through the Spring Boot property `seata.json.serializer-type` or the native Seata property `json.serializerType`, with supported values `jackson`, `fastjson`, `fastjson2`, `gson`, and `jackson3`.
53+
4. Seata 2.7 adds support for `fastjson2` and `jackson3`. If you plan to enable `jackson3`, the runtime environment must be JDK 17 or later.
54+
5. If `jackson3` is configured but its implementation is not available in the current environment, Seata will automatically fall back to `jackson`.
55+
6. Seata 2.7 introduces a JSON deserialization allowlist mechanism. If a business object is deserialized from JSON with type information and the target class is not in the allowlist, you may see a `Class not in JSON deserialization allowlist` exception.
56+
7. To allow custom business classes, you can extend the allowlist with `seata.json.allowlist=com.example.order.,com.example.dto.,com.example.CustomContext`; a value ending with `.` means package prefix matching, while a value without `.` means exact class name matching.
57+
8. The default allowlist already includes common JDK primitive types, collection types, time types, and the package prefixes `org.apache.seata.` and `io.seata.`.
58+
9. The old TCC-specific properties `seata.tcc.context-json-parser-type` / `tcc.contextJsonParserType` are still read as a compatibility fallback, but they have been deprecated since 2.7.0. If both old and new properties exist, the new `json.serializerType` takes precedence.
59+
</details>
60+
4261
------
4362
<h3 id='11'>11. What compatibility matters need to be paid attention to when upgrading to seata 2.5?</h3>
4463
<details>

i18n/en/docusaurus-plugin-content-docs/current/overview/faq.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ Error: A fatal exception has occurred. Program will exit.?</a>
147147
<a href="#46" target="_self">46. Why does Seata report LockWaitTimeoutException due to table name case sensitivity in global transaction lock reentrancy? </a>
148148
<br/>
149149

150+
<a href="#47" target="_self">47. What is `json-common` used for?</a>
151+
<br/>
152+
153+
<a href="#48" target="_self">48. Do I have to switch to `fastjson2` or `jackson3` after upgrading to 2.7?</a>
154+
<br/>
155+
156+
<a href="#49" target="_self">49. In what scenarios should I pay attention to the JSON deserialization allowlist?</a>
157+
<br/>
158+
159+
<a href="#50" target="_self">50. When is it appropriate to use `jackson3`?</a>
160+
<br/>
161+
150162
---
151163

152164
<h3 id='1'>Q: 1.Can Seata be used in a production environment?</h3>
@@ -773,3 +785,63 @@ public class SetSeataInterceptor implements RequestInterceptor {
773785
- Remove useOldAliasMetadataBehavior=true from your MySQL JDBC URL or set it to false.
774786
775787
---
788+
789+
<h3 id='47'>Q: 47. What is `json-common` used for?</h3>
790+
791+
**A:** `json-common` is Seata's unified JSON abstraction layer. It centralizes Seata's internal JSON SPI, utility classes, and security checks. The most direct current use case is JSON serialization and deserialization for TCC `BusinessActionContext`.
792+
793+
It mainly serves three purposes:
794+
795+
1. Unify JSON implementation selection, supporting `fastjson`, `fastjson2`, `jackson`, `jackson3`, and `gson`
796+
2. Provide a unified entry for internal JSON serialization and deserialization in Seata
797+
3. Add allowlist-based security control for deserialization with type information
798+
799+
---
800+
801+
<h3 id='48'>Q: 48. Do I have to switch to `fastjson2` or `jackson3` after upgrading to 2.7?</h3>
802+
803+
**A:** No. The default JSON serializer is now `jackson`. The introduction of `json-common` is primarily for capability unification and stronger security controls, not to force an immediate switch to `fastjson2` or `jackson3` during upgrade.
804+
805+
If you want to switch the JSON serializer, Spring Boot applications should use:
806+
807+
```yaml
808+
seata:
809+
json:
810+
serializer-type: fastjson2
811+
```
812+
813+
Native Seata configuration should use:
814+
815+
```properties
816+
json.serializerType=fastjson2
817+
```
818+
819+
The old TCC-specific properties `seata.tcc.context-json-parser-type` / `tcc.contextJsonParserType` are still read as a compatibility fallback, but they have been deprecated since 2.7.0.
820+
821+
---
822+
823+
<h3 id='49'>Q: 49. In what scenarios should I pay attention to the JSON deserialization allowlist?</h3>
824+
825+
**A:** Pay special attention in the following scenarios:
826+
827+
1. Custom business objects are stored in the TCC context
828+
2. Your business relies on type metadata such as `@type` to restore concrete subclasses
829+
3. Extensions directly use Seata's JSON SPI for deserialization with type information
830+
831+
If you see a `Class not in JSON deserialization allowlist` exception after upgrading, add the corresponding business classes to `seata.json.allowlist`, for example:
832+
833+
```properties
834+
seata.json.allowlist=com.example.order.,com.example.tcc.,com.example.CustomContext
835+
```
836+
837+
Here, a value ending with `.` means package prefix matching, while a value without `.` means exact class name matching.
838+
839+
---
840+
841+
<h3 id='50'>Q: 50. When is it appropriate to use `jackson3`?</h3>
842+
843+
**A:** You can consider enabling `jackson3` when your runtime environment is already JDK 17 or later and you want to use the Jackson 3 ecosystem. If you still have JDK 8 or JDK 11 environments, it is better not to switch yet.
844+
845+
If `jackson3` is configured but its implementation is not available in the current environment, Seata will automatically fall back to `jackson`.
846+
847+
---

i18n/zh-cn/docusaurus-plugin-content-docs/current/ops/upgrade.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ description: Seata upgrade.
66

77
# 版本升级指南
88

9+
<a href="#12" target="_self">12. 升级到 seata 2.7 有哪些兼容性事项是需要注意的?</a>
10+
<br/>
11+
912
<a href="#11" target="_self">11. 升级到 seata 2.5 有哪些兼容性事项是需要注意的?</a>
1013
<br/>
1114

@@ -42,6 +45,23 @@ description: Seata upgrade.
4245

4346
------
4447

48+
<h3 id='12'>12. 升级到 seata 2.7 有哪些兼容性事项是需要注意的?</h3>
49+
<details>
50+
<summary><mark>注意事项</mark></summary>
51+
52+
1. Seata 2.7 新增统一 JSON 模块 `json-common`,用于统一 Seata 内部的 JSON 序列化、反序列化和安全控制能力。
53+
2. 当前默认 JSON 序列化器为 `jackson`。未显式配置 JSON 序列化器时,`JsonUtil` 会解析为 `jackson`
54+
3. JSON 序列化器推荐通过 Spring Boot 配置 `seata.json.serializer-type` 或 Seata 原生配置 `json.serializerType` 切换,可选值为 `jackson``fastjson``fastjson2``gson``jackson3`
55+
4. Seata 2.7 新增 `fastjson2``jackson3` 支持;如果计划启用 `jackson3`,运行环境需要为 JDK 17 及以上。
56+
5. 如果配置了 `jackson3`,但当前环境中 `jackson3` 实现不可用,Seata 会自动降级到 `jackson`
57+
6. Seata 2.7 新增 JSON 反序列化 allowlist 机制。若业务对象通过带类型信息的 JSON 参与反序列化,而目标类不在 allowlist 中,可能出现 `Class not in JSON deserialization allowlist` 异常。
58+
7. 如需放行业务自定义类,可通过 `seata.json.allowlist=com.example.order.,com.example.dto.,com.example.CustomContext` 补充 allowlist;以 `.` 结尾表示包前缀匹配,不以 `.` 结尾表示精确类名匹配。
59+
8. 默认 allowlist 已包含常见 JDK 基础类型、集合类型、时间类型,以及 `org.apache.seata.``io.seata.` 包前缀。
60+
9. 旧的 TCC 专用配置 `seata.tcc.context-json-parser-type` / `tcc.contextJsonParserType` 仍可作为兼容兜底读取,但从 2.7.0 起已废弃;如果新旧配置同时存在,优先使用新的 `json.serializerType`
61+
</details>
62+
63+
------
64+
4565
<h3 id='11'>11. 升级到 seata 2.5 有哪些兼容性事项是需要注意的?</h3>
4666
<details>
4767
<summary><mark>注意事项</mark></summary>

i18n/zh-cn/docusaurus-plugin-content-docs/current/overview/faq.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ Error: A fatal exception has occurred. Program will exit.导致 seata-server 无
147147
<a href="#46" target="_self">46. Seata 全局事务锁重入时,为什么会因表名大小写问题报 LockWaitTimeoutException? </a>
148148
<br/>
149149

150+
<a href="#47" target="_self">47. `json-common` 是用来做什么的?</a>
151+
<br/>
152+
153+
<a href="#48" target="_self">48. 升级到 2.7 后必须切换到 `fastjson2``jackson3` 吗?</a>
154+
<br/>
155+
156+
<a href="#49" target="_self">49. 什么场景下需要关注 JSON 反序列化 allowlist?</a>
157+
<br/>
158+
159+
<a href="#50" target="_self">50. 什么时候适合使用 `jackson3`?</a>
160+
<br/>
161+
150162
---
151163

152164
<h3 id='1'>Q: 1.Seata 目前可以用于生产环境吗?</h3>
@@ -770,3 +782,63 @@ public class SetSeataInterceptor implements RequestInterceptor {
770782
- 从 MySQL JDBC 连接 URL 中移除`useOldAliasMetadataBehavior=true`参数,或将其设置为`false`。
771783
772784
---
785+
786+
<h3 id='47'>Q: 47. `json-common` 是用来做什么的?</h3>
787+
788+
**A:** `json-common` 是 Seata 的统一 JSON 抽象层,用来统一 Seata 内部的 JSON SPI、工具类和安全校验逻辑。当前最直接的使用场景是 TCC `BusinessActionContext` 的 JSON 序列化与反序列化。
789+
790+
它主要有三个作用:
791+
792+
1. 统一 JSON 实现选择,支持 `fastjson`、`fastjson2`、`jackson`、`jackson3`、`gson`
793+
2. 统一 Seata 内部 JSON 的序列化和反序列化入口
794+
3. 为带类型信息的反序列化增加 allowlist 安全控制
795+
796+
---
797+
798+
<h3 id='48'>Q: 48. 升级到 2.7 后必须切换到 `fastjson2` 或 `jackson3` 吗?</h3>
799+
800+
**A:** 不需要。当前默认 JSON 序列化器为 `jackson`。`json-common` 的引入首先是为了统一能力和增强安全控制,不要求用户在升级时立刻切换到 `fastjson2` 或 `jackson3`。
801+
802+
如果需要切换 JSON 序列化器,Spring Boot 应用推荐使用:
803+
804+
```yaml
805+
seata:
806+
json:
807+
serializer-type: fastjson2
808+
```
809+
810+
Seata 原生配置推荐使用:
811+
812+
```properties
813+
json.serializerType=fastjson2
814+
```
815+
816+
旧的 TCC 专用配置 `seata.tcc.context-json-parser-type` / `tcc.contextJsonParserType` 仍可作为兼容兜底读取,但从 2.7.0 起已废弃。
817+
818+
---
819+
820+
<h3 id='49'>Q: 49. 什么场景下需要关注 JSON 反序列化 allowlist?</h3>
821+
822+
**A:** 下面这些场景需要重点关注:
823+
824+
1. 业务自定义对象被放入 TCC 上下文
825+
2. 业务依赖 `@type` 等类型信息恢复具体子类
826+
3. 扩展模块直接调用 Seata JSON SPI 做带类型反序列化
827+
828+
如果升级后出现 `Class not in JSON deserialization allowlist` 异常,需要把对应业务类加入 `seata.json.allowlist`,例如:
829+
830+
```properties
831+
seata.json.allowlist=com.example.order.,com.example.tcc.,com.example.CustomContext
832+
```
833+
834+
其中,以 `.` 结尾表示包前缀匹配,不以 `.` 结尾表示精确类名匹配。
835+
836+
---
837+
838+
<h3 id='50'>Q: 50. 什么时候适合使用 `jackson3`?</h3>
839+
840+
**A:** 当运行环境已经是 JDK 17 及以上,并且希望使用 Jackson 3 生态时,可以考虑启用 `jackson3`。如果仍然存在 JDK 8 或 JDK 11 环境,建议先不要切换。
841+
842+
如果配置了 `jackson3`,但当前环境中 `jackson3` 实现不可用,Seata 会自动降级到 `jackson`
843+
844+
---

0 commit comments

Comments
 (0)