Repository navigation
Add built-in dispatch creator mode (fastjson2.creator=dispatch) - #7983
Open
zhengjiezxxy wants to merge 1 commit into
Open
zhengjiezxxy wants to merge 1 commit into
zhengjiezxxy wants to merge 1 commit into
Conversation
Add ObjectWriterCreatorAsmDispatch and ObjectReaderCreatorAsmDispatch, which create the ASM writer/reader with the ClassLoader of the target class. - If the ClassLoader of the default ObjectWriterCreatorASM / ObjectReaderCreatorASM can load the target class, the default creator is used, so the common case is unchanged. - Otherwise a creator is created per ClassLoader and cached, so generated classes always live in a DynamicClassLoader that can resolve the target class. This fixes ASM creation for classes from other ClassLoaders (OSGi, multiple web apps, hot deployment). - cleanup(ClassLoader) / cleanupAll() release cached creators, so a ClassLoader can be garbage collected after undeployment. Enable with -Dfastjson2.creator=dispatch or fastjson2.creator=dispatch in fastjson2.properties. Tests cover creator resolution, caching, cleanup and serialization/deserialization of a class loaded by an external ClassLoader. <details> <summary>中文说明</summary> 新增内置 dispatch 模式(fastjson2.creator=dispatch),新增 ObjectWriterCreatorAsmDispatch 与 ObjectReaderCreatorAsmDispatch,按照目标类的 ClassLoader 分派读写器的创建。 - 如果默认 ObjectWriterCreatorASM / ObjectReaderCreatorASM 的 ClassLoader 能找到目标类, 直接使用默认 creator,常规场景行为不变。 - 否则按 ClassLoader 创建并缓存独立的 creator,保证生成的类位于能解析目标类的 DynamicClassLoader 中,修复其他 ClassLoader 加载的类(OSGi、同 JVM 多 Web 应用、 热部署等)无法使用 ASM 的问题。 - 提供 cleanup(ClassLoader) / cleanupAll() 外部清理接口,卸载后 ClassLoader 可被回收。 通过 -Dfastjson2.creator=dispatch 或 fastjson2.properties 中的 fastjson2.creator=dispatch 启用。测试覆盖 creator 解析、缓存、清理以及外部 ClassLoader 加载类的序列化/反序列化。 </details>
|
|
This branch has not been deployed
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.
Add ObjectWriterCreatorAsmDispatch and ObjectReaderCreatorAsmDispatch, which create the ASM writer/reader with the ClassLoader of the target class.
Enable with -Dfastjson2.creator=dispatch or fastjson2.creator=dispatch in fastjson2.properties. Tests cover creator resolution, caching, cleanup and serialization/deserialization of a class loaded by an external ClassLoader.
中文说明
新增内置 dispatch 模式(fastjson2.creator=dispatch),新增
ObjectWriterCreatorAsmDispatch 与 ObjectReaderCreatorAsmDispatch,按照目标类的 ClassLoader 分派读写器的创建。
通过 -Dfastjson2.creator=dispatch 或 fastjson2.properties 中的 fastjson2.creator=dispatch 启用。测试覆盖 creator 解析、缓存、清理以及外部 ClassLoader 加载类的序列化/反序列化。
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: