Repository navigation
fix: add setter for FastjsonConfig.writer/readerContext, for issue #4000 #4008
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -268,7 +268,7 @@ public void clearContext() { | |||||||||||||||||||||||||||||
| writerContext = null; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public JSONReader.Context readerContext() { | ||||||||||||||||||||||||||||||
| public JSONReader.Context getReaderContext() { | ||||||||||||||||||||||||||||||
| JSONReader.Context context = readerContext; | ||||||||||||||||||||||||||||||
| if (context == null) { // Concurrency may occur, but it will not cause any problems | ||||||||||||||||||||||||||||||
| context = new JSONReader.Context(JSONFactory.getDefaultObjectReaderProvider(), jsonb ? symbolTable : null, readerFilters, readerFeatures); | ||||||||||||||||||||||||||||||
|
|
@@ -278,7 +278,7 @@ public JSONReader.Context readerContext() { | |||||||||||||||||||||||||||||
| return context; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public JSONWriter.Context writerContext() { | ||||||||||||||||||||||||||||||
| public JSONWriter.Context getWriterContext() { | ||||||||||||||||||||||||||||||
|
jujn marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||
| JSONWriter.Context context = writerContext; | ||||||||||||||||||||||||||||||
| if (context == null) { | ||||||||||||||||||||||||||||||
| context = new JSONWriter.Context(dateFormat, writerFeatures); | ||||||||||||||||||||||||||||||
|
|
@@ -293,4 +293,32 @@ public JSONWriter.Context writerContext() { | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return context; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * Gets the JSONReader context. | ||||||||||||||||||||||||||||||
| * @deprecated Use {@link #getReaderContext()} instead to comply with JavaBean naming conventions. | ||||||||||||||||||||||||||||||
| * @return the JSONReader context | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| @Deprecated | ||||||||||||||||||||||||||||||
| public JSONReader.Context readerContext() { | ||||||||||||||||||||||||||||||
| return getReaderContext(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||
| * Gets the JSONWriter context. | ||||||||||||||||||||||||||||||
| * @deprecated Use {@link #getWriterContext()} instead to comply with JavaBean naming conventions. | ||||||||||||||||||||||||||||||
| * @return the JSONWriter context | ||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||
| @Deprecated | ||||||||||||||||||||||||||||||
| public JSONWriter.Context writerContext() { | ||||||||||||||||||||||||||||||
| return getWriterContext(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| public void setReaderContext(JSONReader.Context context) { | ||||||||||||||||||||||||||||||
| this.readerContext = context; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+317
to
+319
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The new setters store the injected context in the same Suggested fix: document the interaction on both setters (or hold the injected context in a separate field so config setters invalidate only the derived cache and the getter prefers the injected value):
Suggested change
中文说明新增的 setter 将注入的 context 保存在 建议修复:在两个 setter 上补充 Javadoc 说明该交互(或将注入的 context 保存在独立字段中,使配置 setter 仅失效派生缓存,且 getter 优先使用注入的值)。 — qwen3.8-max-preview via Qwen Code /review |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] 新增的
/**
* 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 |
||||||||||||||||||||||||||||||
| public void setWriterContext(JSONWriter.Context context) { | ||||||||||||||||||||||||||||||
| this.writerContext = context; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+321
to
+323
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The cached context is consumed in exactly two places, both in extension-spring5's Suggested fix: at minimum, document the actual scope on the setters; better, route the other consumers (starting with the spring6 converter) through the context accessors so the setter means the same thing everywhere:
Suggested change
中文说明缓存的 context 仅在 extension-spring5 的 建议修复:至少在 setter 上以 Javadoc 说明实际生效范围;更好的做法是让其他消费者(从 spring6 转换器开始)改为通过 context 访问器调用,使 setter 在所有模块中语义一致。 — qwen3.8-max-preview via Qwen Code /review |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.