Skip to content

feature: automatic update after BusinessActionContext modify#8140

Merged
funky-eyes merged 8 commits into
apache:2.xfrom
Zhengcy05:feat/automatic-updates-after-context-update
Jun 19, 2026
Merged

feature: automatic update after BusinessActionContext modify#8140
funky-eyes merged 8 commits into
apache:2.xfrom
Zhengcy05:feat/automatic-updates-after-context-update

Conversation

@Zhengcy05

@Zhengcy05 Zhengcy05 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Ⅰ. Describe what this PR did

This PR adds a tracked wrapper for BusinessActionContext.actionContext so that Map-level mutations in the Try phase, such as put, putAll, remove, clear, replace, compute*, and merge, automatically mark updated as true. This reduces the need for business code to call setUpdated(true) manually.

It also adjusts the initialization timing in ActionInterceptorHandler to ensure framework-side setup does not incorrectly trigger updated, 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:

mvn -P '!java17+' -Dremoteresources.skip=true -Djacoco.skip=true -Dmaven.simplify.skip=true -DfailIfNoTests=false -Dmaven.repo.local=/private/tmp/codex-m2 -f pom.xml -pl integration-tx-api -am -Dtest=ActionInterceptorHandlerTest,BusinessActionContextTest test

Verification:

  • BusinessActionContextTest covers actionContext mutations and automatic updated marking.
  • ActionInterceptorHandlerTest covers business-side changes being reported correctly in the Try phase.

Ⅴ. 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.

@funky-eyes funky-eyes added the first-time contributor first-time contributor label Jun 9, 2026
@funky-eyes funky-eyes modified the milestones: 2.7.0, 2.8.0 Jun 9, 2026
@funky-eyes funky-eyes requested a review from Copilot June 9, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Map wrapper in BusinessActionContext that marks updated=true on key Map mutation operations.
  • Enabled action-context mutation tracking in ActionInterceptorHandler after framework initialization to avoid framework-side initialization falsely setting updated.
  • 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.

@Zhengcy05 Zhengcy05 force-pushed the feat/automatic-updates-after-context-update branch from 73e661d to bea4abe Compare June 11, 2026 07:30
@funky-eyes funky-eyes added mode: TCC TCC transaction mode module/tcc tcc module module/intergration-tx-api intergration-tx-api and removed module/tcc tcc module labels Jun 12, 2026
@funky-eyes funky-eyes requested a review from Copilot June 12, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.90%. Comparing base (2f3de1c) to head (69166d2).

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     
Files with missing lines Coverage Δ
...n/tx/api/interceptor/ActionInterceptorHandler.java 75.23% <100.00%> (+0.98%) ⬆️
...apache/seata/rm/tcc/api/BusinessActionContext.java 100.00% <100.00%> (ø)

... and 38 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Zhengcy05 and others added 3 commits June 13, 2026 17:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@funky-eyes funky-eyes changed the title feat:automatic update after BusinessActionContext modify feature: automatic update after BusinessActionContext modify Jun 15, 2026

@funky-eyes funky-eyes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zhengcy05

Copy link
Copy Markdown
Contributor Author

@funky-eyes funky-eyes merged commit bba87e7 into apache:2.x Jun 19, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor first-time contributor mode: TCC TCC transaction mode module/intergration-tx-api intergration-tx-api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TCC模式try方法ctx.getActionContext().put设置的值,二阶段获取不到

3 participants