You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "waterWang (via GitHub)" <gi...@apache.org> on 2026/08/25 02:31:09 UTC
[PR] fix: JavaBeanSerializeUtil handles null key in Map serialization [dubbo]
waterWang opened a new pull request, #16435:
URL: https://github.com/apache/dubbo/pull/16435
## What is the purpose of the change
Fixes #16432: `JavaBeanSerializeUtil.serialize()` throws `IllegalArgumentException("Property name is null")` when serializing a `Map` that contains a `null` key.
`HashMap` permits exactly one `null` key, so this is a legal input. The Map branch in `serializeInternal` explicitly handles null keys (`key == null ? null : createDescriptorIfAbsent(...)`), but the descriptor produced is then rejected by the `notNull` check in `JavaBeanDescriptor.setProperty()`.
## Root cause
In `JavaBeanSerializeUtil.serializeInternal()` Map branch:
```java
map.forEach((key, value) -> {
Object keyDescriptor = key == null ? null : createDescriptorIfAbsent(key, accessor, cache);
Object valueDescriptor = value == null ? null : createDescriptorIfAbsent(value, accessor, cache);
descriptor.setProperty(keyDescriptor, valueDescriptor);
});
```
When the map has a null key, `keyDescriptor` is `null`, and `JavaBeanDescriptor.setProperty(null, value)` throws because of the `notNull(propertyName, "Property name is null")` guard.
## Fix
Relax the `notNull` guard in `JavaBeanDescriptor.setProperty()` for map-type descriptors only — a `null` key is a legal Map key and `LinkedHashMap` (the backing storage) supports it. Bean/array/collection/class/enum descriptors keep the original null check.
## Verification
- Added `testSerialize_MapWithNullKey` (round-trip test: map with a null key serializes, deserializes, and preserves both key-value pairs)
- Existing `JavaBeanSerializeUtilTest` suite unaffected
## Checklist
- [x] I have read and agree to the Contributor Guidelines
- [x] I have added tests that prove my fix is effective
- [x] The PR targets the `3.3` branch
--
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: JavaBeanSerializeUtil handles null key in Map serialization [dubbo]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #16435:
URL: https://github.com/apache/dubbo/pull/16435#issuecomment-5404451716
## [Codecov](https://app.codecov.io/gh/apache/dubbo/pull/16435?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 `0%` with `2 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 29.80%. Comparing base ([`6054104`](https://app.codecov.io/gh/apache/dubbo/commit/605410407c718ea6635be3fb577ceec36f528bff?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`64f1c89`](https://app.codecov.io/gh/apache/dubbo/commit/64f1c896bf4c32d5f55554c79c0b662dd237bc2a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on 3.3.
| [Files with missing lines](https://app.codecov.io/gh/apache/dubbo/pull/16435?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...ache/dubbo/common/beanutil/JavaBeanDescriptor.java](https://app.codecov.io/gh/apache/dubbo/pull/16435?src=pr&el=tree&filepath=dubbo-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fdubbo%2Fcommon%2Fbeanutil%2FJavaBeanDescriptor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb21tb24vYmVhbnV0aWwvSmF2YUJlYW5EZXNjcmlwdG9yLmphdmE=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/dubbo/pull/16435?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 (6054104) and HEAD (64f1c89). Click for more details.
>
> <details><summary>HEAD has 3 uploads less than BASE</summary>
>
>| Flag | BASE (6054104) | HEAD (64f1c89) |
>|------|------|------|
>|samples-tests-java21|1|0|
>|integration-tests-java8|1|0|
>|integration-tests-java21|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 3.3 #16435 +/- ##
============================================
- Coverage 36.93% 29.80% -7.13%
+ Complexity 11752 9435 -2317
============================================
Files 1952 1952
Lines 89249 89250 +1
Branches 13389 13389
============================================
- Hits 32961 26600 -6361
- Misses 51710 58533 +6823
+ Partials 4578 4117 -461
```
| [Flag](https://app.codecov.io/gh/apache/dubbo/pull/16435/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/16435/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/16435/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/16435/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [samples-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16435/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `29.80% <0.00%> (-0.01%)` | :arrow_down: |
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 Harness](https://app.codecov.io/gh/apache/dubbo/pull/16435?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