Repository navigation
fix: enforce transaction isolation for ExcursionReview save operations - #148
huytran2005 wants to merge 2 commits into
Conversation
Extracted the `save` operation from `ExcursionReviewRepository` into a dedicated `ExcursionReviewWriter` component that uses `@Transactional(propagation = Propagation.REQUIRES_NEW)` and `saveAndFlush`. This correctly enforces transaction isolation and immediately triggers database constraint checks (like idempotency key violations), allowing the calling service to catch `DataIntegrityViolationException` rather than relying on an overridden repository method whose transaction settings were ignored by Spring AOP. Co-authored-by: huytran2005 <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Updated `.github/workflows/ci.yml` to specify `java-version: '21'` instead of `25`. This resolves a CI failure caused by the non-LTS Java 25 version conflicting with the project's strict Java 21 LTS requirement and failing the SonarCloud analysis bootstrapping. Co-authored-by: huytran2005 <[email protected]>
|
Closing redundant draft PR created by automated bot. |
a) Problem statement and rationale:
The
ExcursionReviewRepositorypreviously overrode thesavemethod with@Transactional(propagation = Propagation.REQUIRES_NEW). Spring AOP generally ignores transactional annotations on overridden interface methods in favor of the proxy's default propagation behavior. Furthermore, even if applied, without a.flush()call, exceptions likeDataIntegrityViolationExceptionwould only be thrown when the outer transaction committed, thus bypassing the intended fallback logic inExcursionReviewService.submitReview().b) Summary of code and test changes:
savemethod fromExcursionReviewRepository.ExcursionReviewWriter, an isolated@Servicecomponent responsible solely for persisting anExcursionReviewin a new transaction (Propagation.REQUIRES_NEW) usingsaveAndFlush().ExcursionReviewServiceto rely onExcursionReviewWriterfor saving reviews.ExcursionReviewAndAnalyticsTestto verify interactions againstExcursionReviewWriterrather thanExcursionReviewRepository.save.c) Verification commands executed and test results:
chmod +x mvnw && ./mvnw clean install -DskipTeststo package inter-module dependencies../mvnw test -pl cruise-activity-service -Dtest=ExcursionReviewAndAnalyticsTest -qwhich completed perfectly../mvnw test -qto confirm the entire project suite is free of regressions (557 tests passed).d) Any residual limitations or human review recommendations:
@Transactionalrepository overrides, if introduced in the future.PR created automatically by Jules for task 15975188325240945752 started by @huytran2005