waterWang opened a new pull request, #16441: URL: https://github.com/apache/dubbo/pull/16441
## What is the purpose of the change? Fixes #16440 — hessian2 deserialization loses Byte/Short/Float element types in **nested** generic collections (`List<List<Byte>>`, `Map<String, List<Byte>>`), widening them to `Integer`/`Double` on the provider side and causing `ClassCastException` on typed access. ### Root cause hessian2 encodes `Byte`/`Short`/`Integer` all as `int` and `Float`/`Double` as `double` on the wire, so narrow element types can only be restored from the declared generic type. Two problems combined: 1. Request arguments were decoded (`DecodeableRpcInvocation.drawArgs`) with only the erased `Class`, discarding the generic parameter types entirely. 2. Even when a generic `Type` was available, `Hessian2ObjectInput.readObject(Class, Type)` ignored it, and hessian-lite's `expectedTypes` mechanism only handles a single level — nested element types (e.g. the `Byte` inside `Map<String, List<Byte>>`) are still widened. ### How this is fixed - `MethodDescriptor`/`ReflectionMethodDescriptor`: expose `getGenericParameterTypes()`. - `DecodeableRpcInvocation`: capture the generic parameter types when looking up the method and pass them to `ObjectInput.readObject(Class, Type)`. - `Hessian2ObjectInput.readObject(Class, Type)`: when the declared type is a parameterized collection/map containing narrow wrapper types (`Byte`/`Short`/`Float`/`Character`), read the object with the erased type and recursively narrow numeric elements to the declared generic element types. Types without narrowable elements (e.g. `List<String>`) keep the original native path. ### Verification - New unit test `testReadObjectWithNestedGenericType` in `Hessian2SerializationTest` covering `Map<String, List<Byte>>`, `List<List<Byte>>`, `Map<String, List<Float>>`, simple `List<Byte>` and an untouched `List<String>`. - `mvn -pl dubbo-serialization/dubbo-serialization-hessian2 -am test` — all 809 tests pass (incl. 798 `TypeMatchTest`). - `dubbo-common` and `dubbo-rpc/dubbo-rpc-dubbo` compile. ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues/16440) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Write necessary unit-test to verify your logic correction. - [x] Make sure gitHub actions can pass. -- 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]
