fix: add setter for FastjsonConfig.writer/readerContext, for issue #4000#4008
Open
jujn wants to merge 3 commits into
Open
fix: add setter for FastjsonConfig.writer/readerContext, for issue #4000#4008jujn wants to merge 3 commits into
jujn wants to merge 3 commits into
Conversation
wenshao
requested changes
Apr 25, 2026
Collaborator
Author
|
done |
wenshao
approved these changes
Jun 22, 2026
| public void setReaderContext(JSONReader.Context context) { | ||
| this.readerContext = context; | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
[Suggestion] 新增的 setReaderContext() / setWriterContext() 缺少测试覆盖和 Javadoc。
-
测试缺失: PR 新增了 4 个公共方法,但 diff 中没有测试文件变更。建议在
FastJsonConfigTest中补充:(a) setter/getter 往返一致性,(b) PR 描述中的自定义ObjectWriterProvider用例,(c) 废弃方法委托正确性,(d)clearContext()后自定义 context 被清除的行为。 -
缓存失效行为未文档化: 这两个 setter 注入的自定义 context 会被后续
setReaderFeatures()、setDateFormat()等方法通过clearContext()静默清除。JavaBean 的 set/get 命名隐含"值会持续生效"的契约,建议添加 Javadoc 警告此行为:
/**
* Sets a pre-built JSONReader.Context.
* <p><b>Warning:</b> subsequent calls to {@link #setReaderFeatures},
* {@link #setDateFormat}, etc. will invalidate this custom context.
*/
public void setReaderContext(JSONReader.Context context) {
this.readerContext = context;
}— qwen3.7-max via Qwen Code /review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
允许用户像 1.x 中那样限定自定义序列化器影响范围,如下所示:
Summary of your change
Please indicate you've done the following: