Skip to content

fix: enforce Serializable check in PojoUtils.realize when Map has no "class" key#16274

Open
EvanYao826 wants to merge 1 commit into
apache:3.3from
EvanYao826:fix/pojo-realize-serializable-check
Open

fix: enforce Serializable check in PojoUtils.realize when Map has no "class" key#16274
EvanYao826 wants to merge 1 commit into
apache:3.3from
EvanYao826:fix/pojo-realize-serializable-check

Conversation

@EvanYao826
Copy link
Copy Markdown

Fixes #16270


Problem

When a generic Map does not carry a "class" entry, the target type comes from the method signature. The existing Serializable check was only applied when a "class" key was present, allowing non-Serializable DTOs to slip through when the key was absent.

Fix

Add a check in PojoUtils.realize() that rejects non-Serializable types even when the Map has no "class" key. This makes the behavior consistent with the existing check that fires when the key is present.

Changes

  • PojoUtils.java: Added Serializable interface check before the enum handling block
  • PojoUtilsTest.java: Added NonSerializableDto test class and test_realize_rejectsNonSerializableMapWithoutClassKey test

AI-agent involvement: This contribution was assisted by an AI coding agent.

…"class" key

When a generic Map does not carry a "class" entry, the target type comes
from the method signature. The existing Serializable check was only applied
when a "class" key was present, allowing non-Serializable DTOs to slip
through when the key was absent.

Add a check that rejects non-Serializable types even when the Map has no
"class" key, consistent with the behavior when the key is present.

Fixes apache#16270

---
*AI-agent involvement: This contribution was assisted by an AI coding agent.*

Signed-off-by: EvanYao826 <2869018789@qq.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 17, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.96%. Comparing base (3dbba26) to head (8b4cbfd).

Files with missing lines Patch % Lines
.../java/org/apache/dubbo/common/utils/PojoUtils.java 0.00% 5 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (3dbba26) and HEAD (8b4cbfd). Click for more details.

HEAD has 14 uploads less than BASE
Flag BASE (3dbba26) HEAD (8b4cbfd)
samples-tests-java8 2 1
samples-tests-java21 2 1
integration-tests-java8 2 1
integration-tests-java21 2 1
unit-tests-java8 2 0
unit-tests-java25 2 0
unit-tests-java11 2 0
unit-tests-java17 2 0
unit-tests-java21 2 0
Additional details and impacted files
@@              Coverage Diff              @@
##                3.3   #16274       +/-   ##
=============================================
- Coverage     60.85%   36.96%   -23.90%     
+ Complexity    11779    11756       -23     
=============================================
  Files          1953     1952        -1     
  Lines         89186    89170       -16     
  Branches      13454    13372       -82     
=============================================
- Hits          54277    32964    -21313     
- Misses        29353    51630    +22277     
+ Partials       5556     4576      -980     
Flag Coverage Δ
integration-tests-java21 32.18% <0.00%> (+<0.01%) ⬆️
integration-tests-java8 32.24% <0.00%> (-0.02%) ⬇️
samples-tests-java21 32.16% <0.00%> (-0.07%) ⬇️
samples-tests-java8 29.75% <0.00%> (-0.14%) ⬇️
unit-tests-java11 ?
unit-tests-java17 ?
unit-tests-java21 ?
unit-tests-java25 ?
unit-tests-java8 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Generic invocation without class key bypasses Serializable check on PojoUtils.realize

2 participants