feature: automatic update after BusinessActionContext modify#8140
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances Seata TCC’s BusinessActionContext so that direct Map mutations on actionContext during the Try phase automatically mark the context as updated, ensuring those changes are reported and visible in phase two (fixing #7954).
Changes:
- Added an internal tracked
Mapwrapper inBusinessActionContextthat marksupdated=trueon keyMapmutation operations. - Enabled action-context mutation tracking in
ActionInterceptorHandlerafter framework initialization to avoid framework-side initialization falsely settingupdated. - Added/updated tests to verify mutation tracking and the resulting branch report payload behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| integration-tx-api/src/main/java/org/apache/seata/rm/tcc/api/BusinessActionContext.java | Introduces a tracked Map wrapper and opt-in tracking enablement to auto-mark updated on mutations. |
| integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/interceptor/ActionInterceptorHandler.java | Enables actionContext tracking after branch registration / framework initialization. |
| integration-tx-api/src/test/java/org/apache/seata/rm/tcc/api/BusinessActionContextTest.java | Adds unit test coverage for mutation operations triggering updated. |
| integration-tx-api/src/test/java/org/apache/seata/integration/tx/api/interceptor/ActionInterceptorHandlerTest.java | Adds integration-style test ensuring Try-phase mutations are reported into branch application data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
73e661d to
bea4abe
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #8140 +/- ##
============================================
- Coverage 72.92% 72.90% -0.03%
+ Complexity 883 879 -4
============================================
Files 1327 1327
Lines 50769 50848 +79
Branches 6058 6070 +12
============================================
+ Hits 37025 37071 +46
- Misses 10735 10773 +38
+ Partials 3009 3004 -5
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
funky-eyes
left a comment
There was a problem hiding this comment.
LGTM
Please register your PR in those two files :
https://github.com/apache/incubator-seata/blob/2.x/changes/zh-cn/2.x.md
https://github.com/apache/incubator-seata/blob/2.x/changes/en-us/2.x.md
Done. 🫰 |
Ⅰ. Describe what this PR did
This PR adds a tracked wrapper for
BusinessActionContext.actionContextso that Map-level mutations in the Try phase, such asput,putAll,remove,clear,replace,compute*, andmerge, automatically markupdatedastrue. This reduces the need for business code to callsetUpdated(true)manually.It also adjusts the initialization timing in
ActionInterceptorHandlerto ensure framework-side setup does not incorrectly triggerupdated, while business-side changes are still captured and reported correctly in phase two.Ⅱ. Does this pull request fix one issue?
fixes #7954
Ⅲ. Why don't you add test cases (unit test/integration test)?
Test cases have been added to cover the new behavior.
Ⅳ. Describe how to verify it
Run:
Verification:
Ⅴ. Special notes for reviews
This change only covers Map-level tracking for actionContext. It does not add deep proxying or dirty tracking for nested object fields.