Icesource opened a new pull request, #16575: URL: https://github.com/apache/dubbo/pull/16575
## What is the purpose of the change? When an application omits a dependency referenced by a DTO field or generic signature, reflection can throw `NoClassDefFoundError` or `TypeNotPresentException` during automatic serialization allow-list registration. The exception currently aborts the interface scan, leaving otherwise healthy DTOs undiscovered and potentially rejected by STRICT checking. The protocol wrapper catches the exception outside the entire scan, so exporting/referencing the service can still succeed with that incomplete list. Fixes https://github.com/apache/dubbo/issues/16574 Catch missing-type/linkage failures at the reflection traversal boundaries, log the affected metadata, and continue independent fields, types, and methods. Preserve automatic trust settings, the visited-type cache, and rejection of unknown classes under STRICT. The fix does not catch arbitrary `Throwable` or change the check mode. If `getDeclaredFields()` cannot return its field array, skip that class's field enumeration and continue in its caller. This does not repair the application's missing dependency or make an unreadable service-method signature introspectable. ### Regression tests `SerializeSecurityConfiguratorMissingTypeTest` uses an isolated class loader that defines the actual fixture classes but refuses their optional dependency. Eight cases cover raw and transient field types, generic method parameters/returns, generic fields/interfaces/superclasses, and type-variable bounds. Each verifies that healthy DTOs and nested DTOs are discovered while an unrelated class remains rejected under STRICT. - [Regression tests](https://github.com/Icesource/dubbo/blob/cf032ccf6166525f7cb1d8ef703ec196d2cb1f35/dubbo-common/src/test/java/org/apache/dubbo/common/utils/SerializeSecurityConfiguratorMissingTypeTest.java) - [Fixture classes](https://github.com/Icesource/dubbo/blob/cf032ccf6166525f7cb1d8ef703ec196d2cb1f35/dubbo-common/src/test/java/com/serialization/MissingTypeFixtures.java) ### Validation On OpenJDK 17.0.20.1: - Baseline `2d9730c6ab4358d94c6e3594fdd2dca0009fe912`, with only the new tests: all 8 fail with the expected missing-type exceptions. - With the fix: `mvn -B -ntp -pl dubbo-common -am clean test` succeeds — 1,186 tests, 0 failures, 0 errors, 10 skipped. This includes Spotless checks. - No full-repository or RPC end-to-end run was performed for this PR; upstream CI will validate the broader matrix. To reproduce both results in a disposable checkout of this PR (JDK 17): ```sh git clone --branch fix/serialize-scan-missing-types https://github.com/Icesource/dubbo.git dubbo-missing-type-repro cd dubbo-missing-type-repro git checkout cf032ccf6166525f7cb1d8ef703ec196d2cb1f35 # Keep the regression tests but restore the original scanner: all 8 cases fail. git restore --source=2d9730c6ab4358d94c6e3594fdd2dca0009fe912 -- dubbo-common/src/main/java/org/apache/dubbo/common/utils/SerializeSecurityConfigurator.java mvn -B -ntp -pl dubbo-common -am test -Dtest=SerializeSecurityConfiguratorMissingTypeTest -Dsurefire.failIfNoSpecifiedTests=false # Restore the fix and run the complete common module suite. git restore --source=HEAD -- dubbo-common/src/main/java/org/apache/dubbo/common/utils/SerializeSecurityConfigurator.java mvn -B -ntp -pl dubbo-common -am clean test ``` ### Related allow-list work https://github.com/apache/dubbo/issues/16569 and https://github.com/apache/dubbo/pull/16570 address array component traversal in the same scanner. This PR is based directly on upstream `3.3` and is independent of that change. Only issue #16574 is closed by this PR. ## Checklist - [x] There is a [GitHub issue](https://github.com/apache/dubbo/issues/16574) for the change. - [x] The description explains what changes, how, and why. - [x] Regression tests demonstrate the failure and verify the correction. - [ ] GitHub Actions: awaiting upstream CI; local validation is recorded above. -- 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]
