fix: close Serializable check bypass in PojoUtils.realize1 for no-class-key generic calls#16273
Open
cvictory wants to merge 1 commit into
Open
fix: close Serializable check bypass in PojoUtils.realize1 for no-class-key generic calls#16273cvictory wants to merge 1 commit into
cvictory wants to merge 1 commit into
Conversation
…ss-key generic calls Issue #16270: When a generic invocation Map does not contain a "class" key, the type is resolved from the method signature and passed directly to PojoUtils.realize1. Previously the Serializable check in DefaultSerializeClassChecker.loadClass was gated behind an `if (className instanceof String)` guard that short-circuited when the key was absent, allowing non-Serializable POJOs to be instantiated via reflection without any validation. Changes: - DefaultSerializeClassChecker: add checkClass(Class<?>) that enforces the same Serializable contract as loadClass() for an already-resolved Class object. - PojoUtils.realize1: add else-branch after the "class"-key block to call DefaultSerializeClassChecker.checkClass(type) when type is a concrete, non-Map, non-Object class and no "class" key was present in the Map. - Add PojoUtilsSerializableCheckTest with 6 tests covering happy/error/edge paths, including the exact regression case from the issue report.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16273 +/- ##
=============================================
- Coverage 60.85% 36.97% -23.89%
+ Complexity 11779 11764 -15
=============================================
Files 1953 1952 -1
Lines 89186 89175 -11
Branches 13454 13373 -81
=============================================
- Hits 54277 32974 -21303
- Misses 29353 51622 +22269
+ Partials 5556 4579 -977
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
classkey bypasses Serializable check onPojoUtils.realize#16270Mapwithout aclasskey bypasses theSerializablecheck inPojoUtils.realize1. A non-Serializable POJO is silently instantiated via reflection even whendubbo.application.checkSerializable=true.DefaultSerializeClassChecker.loadClass— the only check site — is gated behindif (className instanceof String). When theMaphas noclasskey,classNameisnull, the guard short-circuits, andnewInstance(type)runs without any Serializable validation. The target type (already resolved from the method signature) is never checked.classkeyclasskeyFix
DefaultSerializeClassChecker— addcheckClass(Class<?>):Extracts the Serializable validation logic from
loadClassinto a dedicated method that accepts an already-resolvedClassobject, avoiding a redundant class-name lookup.PojoUtils.realize1— addelsebranch after theclass-key block:The guard excludes
Object, interfaces, andMapsubclasses — types that are not POJO-instantiated on this code path and would cause false positives.Verification
PojoUtilsSerializableCheckTest(new, 6 tests): covers happy/error/edge paths including the exact regression case from the issue.PojoUtilsTest(existing, 44 tests): all pass — no regression.