Repository navigation
refactor: extract datasource unwrapping into an ordered SPI - #804
Pika-Yalei wants to merge 2 commits into
Conversation
|
Thanks — the direction here is right, and the equivalence work looks solid. I traced the old Before this lands, though, I think there is one blocker and a few things worth tightening. 1. This introduces the first runtime
|
|
Correction to my earlier comment — point 1 was wrong, please disregard it. I claimed Native Image would fail at image build time because
Your description already states the conclusion more concisely than I did — "no unsupported The remaining points look addressed to me:
Two small things I would still flag, both non-blocking:
For the record on CI: |
|
CI is fully green here (Test CI JDK 17/21/25/27, both NativeTest legs, CodeQL, Dependency review) — the only thing blocking merge is that The conflict is a single file,
The two are independent, so the resolution is simply keeping both. To avoid losing your work while waiting on that, I opened #808, which merges your two commits onto the current Up to you how to proceed:
Both routes land the same code, so only one should stay open. Thanks for the work on this — the caching follow-up and the Hikari native metadata were the right calls. |
|
Merged — thank you for the work on this. Your two commits are now on
They landed via #808. To explain why it went through a second PR rather than this one: Everything you validated held up on the hosted matrix: JDK 17/21/25/27, both Two things worth carrying forward from the review, both of which you already got right:
Closing this one as superseded by #808. Apologies again for my incorrect first comment about needing a |
What kind of change does this PR introduce?
Description
Fixes #792.
DynamicRoutingDataSource.closeDataSourcecurrently owns optional P6Spy and Seata proxy knowledge. Extract that knowledge into aDataSourceUnwrapperSPI and an ordered chain so another proxy integration can register a Java service provider without editing the routing datasource.META-INF/services/com.baomidou.dynamic.datasource.unwrapper.DataSourceUnwrapperand order them throughOrderedItemDataSourcereal-pool shortcutThe chain deliberately stops at the first successfully unwrapped target rather than recursively stripping proxies, preserving existing lifecycle behavior. Endpoint reporting can reuse the SPI separately; this PR does not change the endpoint.
Impact on the core contracts
@DSresolution /DynamicDataSourceContextHolderswitching and stack semantics@DSTransactional, savepoints, XA/Atomikos, Seata)ENC(...)encryption / configuration propertiesThis is a datasource destruction refactor. It does not change datasource creation, transaction behavior, routing, configuration names, or production dependency scopes. Existing P6Spy/Seata dependencies are reused in test scope only. The new core bytecode was verified as class-file major version 52 (Java 8).
Checklist
clean test buildunder JDK 17, with Boot 2/library compilation and tests using JDK 8 toolchainsValidation and remaining checks
The review follow-up was tested on the exact tree published as
b160b12451f3292fb46e59721fbb453ff35764ec.A fresh
clean test buildunder JDK 17, with Java 8/17 module toolchains and the build cache disabled, passed 241 tests with zero failures, errors, or skips:Both native test tasks passed with the CI-specified GraalVM Community 25.3.4.1:
nativeTest: 38 discovered, 33 executed and passed, 5 existing SpEL-related native skipsnativeTest: 34 discovered, 33 executed and passed, 1 existing SpEL-related native skipThe original published head reproduced a real native issue: image construction succeeded and immediate custom-SPI lifecycle tests passed, but four newly added graceful remove/replace cases failed because
HikariDataSourceActiveDetectorlacked reflection invocation metadata. The follow-up adds only conditional registrations forHikariDataSource.getHikariPoolMXBean()andHikariPool.getActiveConnections()in the shared native metadata module. Both affected native suites now pass. Standard ServiceLoader discovery is retained; no unsupportedservicesmetadata section was added.The PR adds 45 regression cases: 15 SPI contract/lifecycle/classloader cases and 10 shared real-pool lifecycle cases on each starter line. Follow-up coverage verifies lazy chain reuse, changed/unchanged integration flags, null-TCCL fallback and child-only service-descriptor discovery. The chain uses an explicit TCCL-first Spring classloader policy, preserving application-provider visibility. Core SPI bytecode remains class-file major version 52 (Java 8).
The isolated environment used external validation-only init scripts for explicit Mockito startup-agent instrumentation and conservative worker/JVM limits. Native compilation used a 4 GiB heap and two compiler threads. No repository build settings or test exclusions were changed for those environment constraints.
Local verification does not replace the complete hosted JDK 17/21/25/27 matrix. On this exact head, GitHub CI and CodeQL are awaiting maintainer workflow approval (
action_required), rather than reporting test failures.Implementation and test preparation were AI-assisted, followed by independent code review and the local validation above. This PR is open and ready for review; merge remains subject to maintainer review and required hosted checks.