Skip to content

fix: enforce transaction isolation for ExcursionReview save operations - #148

Closed
huytran2005 wants to merge 2 commits into
mainfrom
bugfix/transaction-propagation-excursion-review-15975188325240945752
Closed

huytran2005 wants to merge 2 commits into
mainfrom
bugfix/transaction-propagation-excursion-review-15975188325240945752

Conversation

@huytran2005

Copy link
Copy Markdown
Contributor

a) Problem statement and rationale:
The ExcursionReviewRepository previously overrode the save method 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 like DataIntegrityViolationException would only be thrown when the outer transaction committed, thus bypassing the intended fallback logic in ExcursionReviewService.submitReview().

b) Summary of code and test changes:

  • Removed the overridden save method from ExcursionReviewRepository.
  • Created ExcursionReviewWriter, an isolated @Service component responsible solely for persisting an ExcursionReview in a new transaction (Propagation.REQUIRES_NEW) using saveAndFlush().
  • Refactored ExcursionReviewService to rely on ExcursionReviewWriter for saving reviews.
  • Updated ExcursionReviewAndAnalyticsTest to verify interactions against ExcursionReviewWriter rather than ExcursionReviewRepository.save.

c) Verification commands executed and test results:

  • Executed chmod +x mvnw && ./mvnw clean install -DskipTests to package inter-module dependencies.
  • Verified test suite correctness by executing ./mvnw test -pl cruise-activity-service -Dtest=ExcursionReviewAndAnalyticsTest -q which completed perfectly.
  • Ran ./mvnw test -q to confirm the entire project suite is free of regressions (557 tests passed).

d) Any residual limitations or human review recommendations:

  • No residual limits. Human reviewers might want to ensure similar fixes are applied to any other direct @Transactional repository overrides, if introduced in the future.

PR created automatically by Jules for task 15975188325240945752 started by @huytran2005

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]>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

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]>
@huytran2005

Copy link
Copy Markdown
Contributor Author

Closing redundant draft PR created by automated bot.

@huytran2005
huytran2005 deleted the bugfix/transaction-propagation-excursion-review-15975188325240945752 branch November 15, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant