fix(spring-config): unwrap DataSource at SpringTransactionContextValidator and use it at isInActiveReadWriteTransaction() - #95
Merged
Conversation
…dator and use it at isInActiveReadWriteTransaction()
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a mismatch between Okapi’s startup validation and runtime transaction validation when the outbox DataSource is a Spring DelegatingDataSource proxy (e.g., TransactionAwareDataSourceProxy). It centralizes DataSource unwrapping logic so both checks agree on DataSource identity and avoids per-publish() unwrapping by resolving once at validator construction time.
Changes:
- Extracted
DelegatingDataSourcechain-unwrapping into a shared internal utility (DataSourceUnwrapping.kt) and updated startup validation to use it. - Updated
SpringTransactionContextValidatorto resolve (unwrap) the effective DataSource once during construction and validate transactions against that resolved target. - Reorganized and expanded tests: moved unwrapping unit tests into
DataSourceUnwrappingTest.ktand added runtime validator coverage for proxied, nested, and cyclic/unresolvable chains.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/DataSourceUnwrapping.kt | Introduces shared internal unwrapping result types and unwrapping/diagnostic helpers for DelegatingDataSource chains. |
| okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/SpringTransactionContextValidator.kt | Uses the shared unwrapping utility to validate against the resolved backing DataSource (fail-fast on unresolvable chains). |
| okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OutboxAutoConfiguration.kt | Removes duplicated unwrapping implementation from the companion object and relies on the shared utility in startup checks. |
| okapi-spring-boot/src/test/kotlin/com/softwaremill/okapi/springboot/DataSourceUnwrappingTest.kt | Adds focused unit tests for unwrapping behavior (nested proxies, null targets, cycles). |
| okapi-spring-boot/src/test/kotlin/com/softwaremill/okapi/springboot/SpringTransactionContextValidatorTest.kt | Adds tests ensuring runtime validation succeeds behind proxies and fails fast for cyclic/unresolvable chains. |
| okapi-spring-boot/src/test/kotlin/com/softwaremill/okapi/springboot/OutboxAutoConfigurationTransactionRunnerTest.kt | Removes the previously embedded unwrapping tests now covered by DataSourceUnwrappingTest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
#91
Approach: