uuuyuqi opened a new pull request, #16199: URL: https://github.com/apache/dubbo/pull/16199
Closes #16197 ## Summary Backport of #16198 to the 3.2 branch. When RPC methods have parameters like `List<Byte>`, `Map<String, Byte>`, or `List<Short>`, the provider-side deserialization incorrectly produces `List<Integer>` / `Map<String, Integer>` because the generic type information is discarded during deserialization. This PR fixes the issue across three layers: - **Model layer**: Add `getGenericParameterTypes()` to `MethodDescriptor` (default method for backward compat) and implement it in `ReflectionMethodDescriptor` to expose `Type[]` for method parameters. - **Protocol layer**: Update `DecodeableRpcInvocation.drawArgs()` (Dubbo protocol) and `ReflectionPackableMethod.WrapRequestUnpack` (Triple protocol) to pass generic `Type` to the serialization framework when available. - **Serialization layer**: Fix `Hessian2ObjectInput.readObject(Class, Type)` to post-convert collection/map elements to the correct narrow number type (`Byte`, `Short`, `Float`). No wire protocol changes needed. The fix leverages existing local reflection information on the provider side. ## Changes | Layer | File | Change | |---|---|---| | Model | `MethodDescriptor.java` | Add `default getGenericParameterTypes()` | | Model | `ReflectionMethodDescriptor.java` | Store and return generic parameter types | | Dubbo Protocol | `DecodeableRpcInvocation.java` | Pass generic `Type` in `drawArgs()` | | Triple Protocol | `ReflectionPackableMethod.java` | Pass generic `Type` in `WrapRequestUnpack` | | Serialization API | `MultipleSerialization.java` | Add `deserialize(url, type, clz, genericType, is)` overload | | Serialization API | `DefaultMultipleSerialization.java` | Implement the new overload | | Serialization Impl | `Hessian2ObjectInput.java` | Post-convert collection/map elements to narrow types | ## Test plan - [x] Unit tests for `ReflectionMethodDescriptor.getGenericParameterTypes()` - [x] Unit tests for `Hessian2ObjectInput.readObject(Class, Type)` with `List<Byte>`, `List<Short>`, `List<Float>`, `Map<String, Byte>` - [x] E2E tested with Dubbo protocol + hessian2: all Byte elements correctly deserialized - [x] E2E tested with Triple protocol + hessian2: all Byte elements correctly deserialized - [x] Verified with Arthas that new code paths are executed at runtime - [x] Reproduced the bug on official Dubbo 3.3.6, confirmed the fix resolves it Made with [Cursor](https://cursor.com) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
