You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "uuuyuqi (via GitHub)" <gi...@apache.org> on 2026/04/09 08:38:09 UTC
[PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
uuuyuqi opened a new pull request, #16198:
URL: https://github.com/apache/dubbo/pull/16198
Closes #16197
## Summary
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "RainYuY (via GitHub)" <gi...@apache.org>.
RainYuY commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4233590352
I'm sorry, but I don't think this problem needs to be fixed. Because the real reason why we cannot serialize it is that the Hessian types do not include byte. So the byte and Integer use the same tag value. If you fix this one, it will have the same problem like List<List<Integer>>, so I think the best way is to fix it in the Hessian protocol (hard), or change the serialization protocol.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4212953590
## [Codecov](https://app.codecov.io/gh/apache/dubbo/pull/16198?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `20.83333%` with `57 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 32.20%. Comparing base ([`8814afa`](https://app.codecov.io/gh/apache/dubbo/commit/8814afac6b2106cfc0d4050ac8318df5774e560d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f5f5ef1`](https://app.codecov.io/gh/apache/dubbo/commit/f5f5ef188d9372d7b62d7b5cb35c30fd7c78a775?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/dubbo/pull/16198?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...common/serialize/hessian2/Hessian2ObjectInput.java](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&filepath=dubbo-serialization%2Fdubbo-serialization-hessian2%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Fcommon%2Fserialize%2Fhessian2%2FHessian2ObjectInput.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tc2VyaWFsaXphdGlvbi9kdWJiby1zZXJpYWxpemF0aW9uLWhlc3NpYW4yL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vc2VyaWFsaXplL2hlc3NpYW4yL0hlc3NpYW4yT2JqZWN0SW5wdXQuamF2YQ==) | 12.24% | [38 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...common/serialize/DefaultMultipleSerialization.java](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&filepath=dubbo-serialization%2Fdubbo-serialization-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Fcommon%2Fserialize%2FDefaultMultipleSerialization.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tc2VyaWFsaXphdGlvbi9kdWJiby1zZXJpYWxpemF0aW9uLWFwaS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vY29tbW9uL3NlcmlhbGl6ZS9EZWZhdWx0TXVsdGlwbGVTZXJpYWxpemF0aW9uLmphdmE=) | 0.00% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...bbo/rpc/protocol/tri/ReflectionPackableMethod.java](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&filepath=dubbo-rpc%2Fdubbo-rpc-triple%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Frpc%2Fprotocol%2Ftri%2FReflectionPackableMethod.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy10cmlwbGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JwYy9wcm90b2NvbC90cmkvUmVmbGVjdGlvblBhY2thYmxlTWV0aG9kLmphdmE=) | 50.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...bo/rpc/protocol/dubbo/DecodeableRpcInvocation.java](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&filepath=dubbo-rpc%2Fdubbo-rpc-dubbo%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Frpc%2Fprotocol%2Fdubbo%2FDecodeableRpcInvocation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy1kdWJiby9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vcnBjL3Byb3RvY29sL2R1YmJvL0RlY29kZWFibGVScGNJbnZvY2F0aW9uLmphdmE=) | 60.00% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...a/org/apache/dubbo/rpc/model/MethodDescriptor.java](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&filepath=dubbo-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Frpc%2Fmodel%2FMethodDescriptor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9ycGMvbW9kZWwvTWV0aG9kRGVzY3JpcHRvci5qYXZh) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../dubbo/common/serialize/MultipleSerialization.java](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&filepath=dubbo-serialization%2Fdubbo-serialization-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Fcommon%2Fserialize%2FMultipleSerialization.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tc2VyaWFsaXphdGlvbi9kdWJiby1zZXJpYWxpemF0aW9uLWFwaS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZHViYm8vY29tbW9uL3NlcmlhbGl6ZS9NdWx0aXBsZVNlcmlhbGl6YXRpb24uamF2YQ==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (8814afa) and HEAD (f5f5ef1). Click for more details.
>
> <details><summary>HEAD has 7 uploads less than BASE</summary>
>
>| Flag | BASE (8814afa) | HEAD (f5f5ef1) |
>|------|------|------|
>|integration-tests-java8|1|0|
>|integration-tests-java21|1|0|
>|unit-tests-java8|1|0|
>|unit-tests-java25|1|0|
>|unit-tests-java11|1|0|
>|unit-tests-java21|1|0|
>|unit-tests-java17|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 3.3 #16198 +/- ##
=============================================
- Coverage 60.79% 32.20% -28.59%
+ Complexity 11751 10229 -1522
=============================================
Files 1953 1953
Lines 89119 89163 +44
Branches 13444 13381 -63
=============================================
- Hits 54177 28719 -25458
- Misses 29368 56223 +26855
+ Partials 5574 4221 -1353
```
| [Flag](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [integration-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [samples-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `32.17% <20.83%> (-0.01%)` | :arrow_down: |
| [samples-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `29.67% <20.83%> (-0.15%)` | :arrow_down: |
| [unit-tests-java11](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java17](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java25](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16198/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/dubbo/pull/16198?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "uuuyuqi (via GitHub)" <gi...@apache.org>.
uuuyuqi commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4234309627
@zrlw Fixed. The previous implementation passed all generic type arguments as `expectedTypes` to `readObject(Class, Class<?>...)`, but the `expectedTypes` mechanism in hessian-lite only works for primitive types. For complex POJOs (like `User`), it bypasses tag-driven deserialization and causes `HessianProtocolException`.
Now only `isPrimitive()` types are passed as `expectedTypes`, consistent with hessian-lite's `FieldDeserializer2Factory`. POJO types fall back to default tag-driven deserialization and are not affected.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "uuuyuqi (via GitHub)" <gi...@apache.org>.
uuuyuqi commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4219646137
@oxsean Thanks for the review! Here is the complete reproduction demo:
**Demo repo**: https://github.com/uuuyuqi/dubbo3-list-byte-bug-demo
Clone, start Nacos, run `mvn spring-boot:run` for provider & consumer, then `curl http://localhost:8082/testByte`. With Dubbo 3.3.6, all `Byte` elements become `Integer` on the provider side.
### Root cause explained
The issue is specific to **hessian2 serialization** with narrow number types (`Byte`, `Short`, `Float`) inside collections/maps. It is **not** about generic calls or `PojoUtils` — this happens with normal strongly-typed RPC calls.
Here is why:
1. **Hessian2 does not preserve the concrete type for small integers during serialization.** When hessian2 serializes a `Byte` value like `(byte) 1`, it writes it as a compact integer (single-byte encoding `0x91`). There is no type tag distinguishing `Byte` from `Integer` — it's just a number in the wire format. This is by design in the hessian2 protocol for compactness.
2. **During deserialization, hessian2 reads this compact integer and produces `Integer` by default**, because it has no information about the target element type. The call chain is:
```
DecodeableRpcInvocation.drawArgs()
→ in.readObject(List.class) // only raw Class, no generic info
→ hessian2 deserializes the list
→ reads each element as Integer // no way to know it should be Byte
```
3. **The generic type information IS available** via `Method.getGenericParameterTypes()` on the provider side (local reflection, no wire transmission needed), but Dubbo never passes it to the serialization layer. The `ObjectInput.readObject(Class, Type)` API already exists in Dubbo's serialization interface but was never utilized in the deserialization path.
This fix simply connects the existing dots:
- `ReflectionMethodDescriptor` already calls `method.getParameterTypes()` → now also calls `method.getGenericParameterTypes()`
- `DecodeableRpcInvocation.drawArgs()` already calls `in.readObject(Class)` → now calls `in.readObject(Class, Type)` when generic info is available
- `Hessian2ObjectInput.readObject(Class, Type)` already exists but ignored the `Type` param → now uses it to post-convert narrow number types
No changes to the wire protocol, no impact on non-generic parameters (the `Type` equals the raw `Class` for non-parameterized types, so the original code path is used).
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4221893906
@uuuyuqi you'd better add testcase that the interface has complex object which has narrow number bytes fields. e.g.,
```
public interface DemoService {
void processPerson(Person person);
}
public static class Person {
String name;
byte age;
short height;
float salary;
}
```
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "uuuyuqi (via GitHub)" <gi...@apache.org>.
uuuyuqi commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4229486159
改成直接用 `Hessian2Input.readObject(Class cl, Class<?>... expectedTypes)` 了,不再做二次转换。已更新。
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4233361581
jobs/testjob_1-result-java21.txt:[11/35] [dubbo-samples-triple-rest-springmvc:1/1] TEST FAILURE: Run tests failed, version: -Ddubbo.version=3.3.7-SNAPSHOT -Dspring.version=6.1.5 -Djava.version=21, please check logs: /home/runner/work/dubbo/dubbo/2-advanced/dubbo-samples-triple-rest/dubbo-samples-triple-rest-springmvc/target/logs
jobs/testjob_2-result-java21.txt:[11/35] [dubbo-samples-triple-rest-jaxrs:1/1] TEST FAILURE: Run tests failed, version: -Ddubbo.version=3.3.7-SNAPSHOT -Dspring.version=6.1.5 -Djava.version=21, please check logs: /home/runner/work/dubbo/dubbo/2-advanced/dubbo-samples-triple-rest/dubbo-samples-triple-rest-jaxrs/target/logs
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "uuuyuqi (via GitHub)" <gi...@apache.org>.
uuuyuqi commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4234310965
@RainYuY You're right that Hessian protocol doesn't have a native byte type — byte and int share the same tag. But hessian-lite already handles this through `readObject(Class, Class<?>... expectedTypes)`: when `CollectionDeserializer` receives expectedTypes, it calls `Number.byteValue()` / `Number.shortValue()` etc. to narrow the type.
The issue was that Dubbo's invocation chain didn't pass generic type info down to hessian-lite, so this existing conversion capability was never triggered. This fix simply propagates the generic parameter types that are already available via reflection, letting hessian-lite's own type narrowing logic work as designed. No new conversion logic is introduced.
For nested generics like `List<List<Byte>>`, yes, that's a limitation of hessian-lite's `expectedTypes` which only supports one level of type arguments. But that's a separate issue and not in scope here — this fix addresses the common single-level cases (`List<Byte>`, `Map<String, Byte>`, etc.) which are the most frequently encountered.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4234278387
> I'm sorry, but I don't think this problem needs to be fixed. Because the real reason why we cannot serialize it is that the Hessian types do not include byte. So the byte and Integer use the same tag value. If you fix this one, it will have the same problem like `List<List<Integer>>`, so I think the best way is to fix it in the Hessian protocol (hard), or change the serialization protocol.
how about ```List<Map<String, Byte>>``` or ```Map<String, List<Byte>>```?
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "oxsean (via GitHub)" <gi...@apache.org>.
oxsean commented on code in PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#discussion_r3062853109
##########
dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2ObjectInput.java:
##########
@@ -119,14 +128,96 @@ public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException
}
@Override
+ @SuppressWarnings("unchecked")
public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException {
if (!Objects.equals(
mH2i.getSerializerFactory().getClassLoader(),
Thread.currentThread().getContextClassLoader())) {
mH2i.setSerializerFactory(hessian2FactoryManager.getSerializerFactory(
Thread.currentThread().getContextClassLoader()));
}
- return readObject(cls);
+ T result = readObject(cls);
Review Comment:
Consider using readObject(Class cl, Class<?>... expectedTypes) to avoid a second conversion.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "uuuyuqi (via GitHub)" <gi...@apache.org>.
uuuyuqi commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4222118656
@zrlw Thanks for the suggestion! I've added a test case with `NarrowNumberPojo` that has `byte age`, `short height`, `float salary` fields, plus `List<Byte> scores` and `Map<String, Byte> attributes` fields.
The test (`testReadObjectWithGenericType_pojoWithNarrowNumberFields`) verifies that:
- Primitive narrow number fields (`byte`, `short`, `float`) are deserialized correctly
- `List<Byte>` and `Map<String, Byte>` fields inside the POJO are also deserialized correctly
- The fix does not affect POJO deserialization in any way
This is expected because when the method parameter is a POJO (e.g., `processPerson(Person person)`), `genericParameterTypes[i]` equals `pts[i]` (both are `Person.class`), so the code falls through to the original `readObject(Class)` path — POJO fields are handled by hessian2's `JavaDeserializer` which already reads field type info from the class definition.
All 16 tests pass locally.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix: preserve generic parameter types during deserialization to fix List → List [3.3] [dubbo]
Posted by "zrlw (via GitHub)" <gi...@apache.org>.
zrlw commented on PR #16198:
URL: https://github.com/apache/dubbo/pull/16198#issuecomment-4233365550
2026-04-11T13:28:00.3369064Z org.apache.dubbo.remoting.http12.exception.DecodeException: status=500, Internal Server Error
2026-04-11T13:28:00.3369388Z at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcCompositeCodec.decode(GrpcCompositeCodec.java:105)
2026-04-11T13:28:00.3369710Z at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcCompositeCodec.decode(GrpcCompositeCodec.java:111)
2026-04-11T13:28:00.3370019Z at org.apache.dubbo.remoting.http12.message.HttpMessageDecoder.decode(HttpMessageDecoder.java:56)
2026-04-11T13:28:00.3370387Z at org.apache.dubbo.remoting.http12.message.DefaultListeningDecoder.decode(DefaultListeningDecoder.java:41)
2026-04-11T13:28:00.3371064Z at org.apache.dubbo.rpc.protocol.tri.h12.http2.GenericHttp2ServerTransportListener$DefaultFragmentListener.onFragmentMessage(GenericHttp2ServerTransportListener.java:131)
2026-04-11T13:28:00.3371666Z at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.invokeListener(LengthFieldStreamingDecoder.java:257)
2026-04-11T13:28:00.3372305Z at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcHttp2ServerTransportListener$DetermineMethodDescriptorListener.onFragmentMessage(GrpcHttp2ServerTransportListener.java:212)
2026-04-11T13:28:00.3372740Z at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.invokeListener(LengthFieldStreamingDecoder.java:257)
2026-04-11T13:28:00.3373164Z at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.processBody(LengthFieldStreamingDecoder.java:249)
2026-04-11T13:28:00.3373574Z at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.deliver(LengthFieldStreamingDecoder.java:172)
2026-04-11T13:28:00.3373971Z at org.apache.dubbo.remoting.http12.message.LengthFieldStreamingDecoder.decode(LengthFieldStreamingDecoder.java:79)
2026-04-11T13:28:00.3374517Z at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcHttp2ServerTransportListener$LazyFindMethodListener.onMessage(GrpcHttp2ServerTransportListener.java:180)
2026-04-11T13:28:00.3374949Z at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.doOnData(AbstractServerTransportListener.java:183)
2026-04-11T13:28:00.3375394Z at org.apache.dubbo.rpc.protocol.tri.h12.AbstractServerTransportListener.lambda$onData$1(AbstractServerTransportListener.java:168)
2026-04-11T13:28:00.3375715Z at org.apache.dubbo.common.threadpool.serial.SerializingExecutor.run(SerializingExecutor.java:111)
2026-04-11T13:28:00.3375996Z at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
2026-04-11T13:28:00.3376269Z at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
2026-04-11T13:28:00.3376537Z at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:39)
2026-04-11T13:28:00.3376670Z at java.base/java.lang.Thread.run(Thread.java:1583)
2026-04-11T13:28:00.3377099Z Caused by: com.alibaba.com.caucho.hessian.io.HessianProtocolException: expected map/object at org.apache.dubbo.rest.demo.pojo.User
2026-04-11T13:28:00.3377392Z at com.alibaba.com.caucho.hessian.io.AbstractDeserializer.error(AbstractDeserializer.java:141)
2026-04-11T13:28:00.3377737Z at com.alibaba.com.caucho.hessian.io.AbstractMapDeserializer.readObject(AbstractMapDeserializer.java:68)
2026-04-11T13:28:00.3378091Z at com.alibaba.com.caucho.hessian.io.CollectionDeserializer.readLengthList(CollectionDeserializer.java:121)
2026-04-11T13:28:00.3378351Z at com.alibaba.com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2347)
2026-04-11T13:28:00.3378765Z at org.apache.dubbo.common.serialize.hessian2.Hessian2ObjectInput.readObject(Hessian2ObjectInput.java:137)
2026-04-11T13:28:00.3379306Z at org.apache.dubbo.common.serialize.DefaultSerializationExceptionWrapper$ProxyObjectInput.readObject(DefaultSerializationExceptionWrapper.java:170)
2026-04-11T13:28:00.3379761Z at org.apache.dubbo.common.serialize.DefaultMultipleSerialization.deserialize(DefaultMultipleSerialization.java:58)
2026-04-11T13:28:00.3380236Z at org.apache.dubbo.rpc.protocol.tri.ReflectionPackableMethod$WrapRequestUnpack.deserializeFromWrapper(ReflectionPackableMethod.java:521)
2026-04-11T13:28:00.3380632Z at org.apache.dubbo.rpc.protocol.tri.ReflectionPackableMethod$WrapRequestUnpack.unpack(ReflectionPackableMethod.java:505)
2026-04-11T13:28:00.3380852Z at org.apache.dubbo.rpc.model.WrapperUnPack.unpack(WrapperUnPack.java:37)
2026-04-11T13:28:00.3381098Z at org.apache.dubbo.rpc.model.PackableMethod.parseRequest(PackableMethod.java:73)
2026-04-11T13:28:00.3381414Z at org.apache.dubbo.rpc.protocol.tri.h12.grpc.GrpcCompositeCodec.decode(GrpcCompositeCodec.java:101)
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org