fix: route parameterized Collection types to the list reader - #7814
Open
DarrenChangJR wants to merge 1 commit into
Open
fix: route parameterized Collection types to the list reader#7814DarrenChangJR wants to merge 1 commit into
DarrenChangJR wants to merge 1 commit into
Conversation
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 and why
Parameterized concrete
Collectiontypes not explicitly listed by the basereader module are currently routed to JavaBean readers unless their raw class is
assignable to
ArrayList. They then reject JSON arrays, even though the sameraw classes are correctly treated as collections when passed as
Classvalues.This change makes the parameterized fallback consistent with the raw-class
path by checking
Collection.class.isAssignableFrom(rawClass). The existingObjectReaderImplListretains the concrete collection class and generic itemtype.
Tests
ParameterizedJdkCollectionTestcovers both text JSON and JSONB for:ArrayDequeandPriorityQueue;Vector;LinkedBlockingDeque,LinkedBlockingQueue, andLinkedTransferQueue;PriorityBlockingQueue;CopyOnWriteArraySet.All values are read as
Long, including a value outside theIntegerrange,and each result retains its requested concrete class.
Validation performed:
mvn -pl core validate;corebuild: 7,990 tests, no failures or errors;removed, with unrelated findings unchanged.
Checklist
implementations.
Collectionhandling.中文说明
修改内容和原因
当参数化的具体
Collection类型不在基础 reader 模块的固定列表中时,当前 fallback 只有在原始类型继承
ArrayList的情况下才会选择集合 reader。其他类型会被错误地当作 JavaBean,并在输入 JSON 数组时失败。这与直接传入
同一个原始
Class时的行为不一致。本修改将判断改为
Collection.class.isAssignableFrom(rawClass),使参数化类型和原始类型走相同的集合语义。现有
ObjectReaderImplList会继续保留请求的具体集合类型和泛型元素类型。
测试
ParameterizedJdkCollectionTest对以下类型同时覆盖文本 JSON 和 JSONB:ArrayDeque、PriorityQueue和Vector;LinkedBlockingDeque、LinkedBlockingQueue、LinkedTransferQueue;PriorityBlockingQueue和CopyOnWriteArraySet。所有结果都保留目标具体类型,并把包含超出
Integer范围的数值读取为Long。聚焦测试共 16 个用例通过,Mavenvalidate通过,完整core测试共 7,990 个用例通过;外部 1.2.83 兼容矩阵中恰好消除了 8 个相关差异。