[Bug] TypeUtil.mapToString 方法仅使用第一个非空值的类型来代表 Map<String, Object>,导致异构值反序列化失败
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start at TypeUtil.mapToString and reproduce the issue with a Map<String, Object> containing Long and String values in a Dubbo request body. Trace how the generated type string is used during replay deserialization; done means heterogeneous values replay without a type mismatch or conversion failure.
Written by the indexing model from the issue text.
Description
Search before asking
- I have searched the existing issues before asking.
AREX Test Service
AREX Java Agent (arextest/arex-agent-java)
Current Behavior
在 TypeUtil.mapToString 方法中,逻辑会遍历 Map 的 entries,但仅处理第一个非空 value(由于 break; 语句),并用其类型来生成类型字符串。这假设 Map 中的所有值都是同质的(相同类型)。然而,对于 Map<String, Object> 中包含异构值(例如混合 Long 和 String)的场景,这会导致类型推断错误,在回放(replay)期间的反序列化失败。
Expected Behavior
方法应该:
遍历所有 entries 并处理异构类型(例如生成联合类型字符串,或使用更灵活的表示如 java.lang.Object)。
或者,在文档中说明此限制,并警告用户确保 Map 中的值类型一致。
理想情况下,支持异构 Map 以避免反序列化错误。
Steps To Reproduce
创建一个包含异构值的 Map<String, Object>,例如:JavaMap<String, Object> testMap = new HashMap<>();
testMap.put("key1", 123L); // Long 类型
testMap.put("key2", "hello"); // String 类型
在 AREX 的录制/回放场景中使用这个 Map(例如作为 Dubbo 服务的请求体)。
在录制阶段,mapToString 生成的类型字符串仅基于第一个非空值(例如,如果 "key1" 先遍历,则类型为 java.lang.Long)。
在回放阶段,反序列化时尝试将该类型应用于所有值,导致类型不匹配的值失败(例如,无法将 String 转换为 Long),抛出如 ClassCastException 的异常。
Anything else
No response
Are you willing to submit a pull request to fix on your own?
- Yes I am willing to submit a pull request on my own!
- Dominant language
- Java
- Stars
- 566
- Forks
- 141
- Avg merge
- 36m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from arextest/arex-agent-java
-
bug :lady_beetle:
Difficulty 4/5 3-5 days Newbie friendliness 42/100
arextest/arex-agent-java#626 · 1 comment ·
-
bug :lady_beetle:
Difficulty 4/5 3-5 days Newbie friendliness 38/100
arextest/arex-agent-java#617 ·
-
[Bug] java.lang.NoClassDefFoundError: org/springframework/web/servlet/mvc/method/RequestMappingInfo Openbug :lady_beetle:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
arextest/arex-agent-java#615 ·
-
bug :lady_beetle:
Difficulty 4/5 3-5 days Newbie friendliness 35/100
arextest/arex-agent-java#614 · 1 comment ·
-
[Bug] Redisson below version 3.2 is not supported and there is no writeBehindService implementation. Openbug :lady_beetle:
Difficulty 1/5 Under an hour Newbie friendliness 35/100
arextest/arex-agent-java#609 ·
All issues in arextest/arex-agent-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100