Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@keepConcentration
Copy link
Contributor

@keepConcentration keepConcentration commented Aug 5, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

This PR fixes the incorrect sorting behavior of GlobalTransactionalInterceptorHandler in DefaultInterfaceParser.parserInterfaceToProxy().
Although the order field was being set using getOrder() and setOrder(), it was not being reflected in the sorting logic due to the lack of an overridden order() method.
The fix ensures that all ProxyInvocationHandler implementations, including GlobalTransactionalInterceptorHandler, are sorted based on the intended order value.

Ⅱ. Does this pull request fix one issue?

fixes #7568

This fixes the handler ordering inconsistency described in the related issue.

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@YongGoose YongGoose self-requested a review August 5, 2025 05:12
@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. first-time contributor first-time contributor module/intergration-tx-api intergration-tx-api labels Aug 5, 2025
@funky-eyes funky-eyes added this to the 2.6.0 milestone Aug 5, 2025
Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

Nice work!
Left some comments.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a specific reason why order method wasn’t implemented in AbstractProxyInvocationHandler?
IMO, Implementing order in AbstractProxyInvocationHandler would allow us to take advantage of inheritance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I observed that both SagaAnnotationActionInterceptorHandler and TccActionInterceptorHandler, which inherit from AbstractProxyInvocationHandler, explicitly override the order() method.

To maintain consistency and clarity across all subclasses, I felt it would be more appropriate for GlobalTransactionalInterceptorHandler to do the same, rather than relying on a shared implementation in the abstract class.

Of course, if you believe it would be better to introduce a shared order() implementation in the abstract class, I'm more than happy to follow that direction.
I'm open to adjusting the PR according to your preference or the maintainers' conventions.

Copy link
Member

Choose a reason for hiding this comment

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

I believe adding it to the abstract class would be a better approach, as this way the subclasses aren’t forced to implement it explicitly through inheritance.

@Override
public int getOrder() {
return this.order;
return this.order();
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why the order function needs to return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right — the line should return the order field directly instead of calling this.order(). I will update the code accordingly to return the order field as you suggested !

@keepConcentration
Copy link
Contributor Author

Thank you for the review! Let me summarize the feedback as I understand it:

  1. Implement the order() method in AbstractProxyInvocationHandler:
    @Override
    public int order() {
        return this.order;
    }
  1. Implement the order() method in GlobalTransactionalInterceptorHandler:
    @Override
    public int order() {
        return this.order;
    }

→ With this, all classes implementing ProxyInvocationHandler will now explicitly implement the order() method.

  1. The getOrder() method in AbstractProxyInvocationHandler returns this.order:
    @Override
    public int getOrder() {
        return this.order;
    }

One thing I noticed is that both the order() and getOrder() methods in AbstractProxyInvocationHandler now have the same implementation, which results in a bit of duplication.

Please let me know if this approach looks good to you. I’ll proceed accordingly once I hear back from you.

@YongGoose
Copy link
Member

One thing I noticed is that both the order() and getOrder() methods in AbstractProxyInvocationHandler now have the same implementation, which results in a bit of duplication.

Please let me know if this approach looks good to you. I’ll proceed accordingly once I hear back from you.

Since the original issue was that getOrder wasn’t working correctly, this approach looks fine to me.
@funky-eyes WDYT?

@YongGoose
Copy link
Member

@keepConcentration

Additionally, for the tests, it would be good to declare multiple classes inheriting from AbstractProxyInvocationHandler, assign different order values to each, and verify that they are sorted as intended.

@YongGoose
Copy link
Member

@keepConcentration

When work is done, Don't hesitate to ping me :)

@keepConcentration
Copy link
Contributor Author

@YongGoose

Thank you again for the detailed feedback!
I've updated the implementation based on your suggestions, including:

  • Implemented the order() method in AbstractProxyInvocationHandler
  • Added a test to verify sorting behavior in AbstractProxyInvocationHandler

Please feel free to take another look when you have time.
Let me know if there’s anything else I should adjust 🙏

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

Please resolve the conflicts.

@keepConcentration
Copy link
Contributor Author

@YongGoose

Ok, I resolved!

@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 61.30%. Comparing base (a9e19b7) to head (a960f85).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...ceptor/handler/AbstractProxyInvocationHandler.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##                2.x    #7570   +/-   ##
=========================================
  Coverage     61.30%   61.30%           
  Complexity      658      658           
=========================================
  Files          1311     1310    -1     
  Lines         49567    49568    +1     
  Branches       5834     5834           
=========================================
+ Hits          30385    30388    +3     
+ Misses        16461    16460    -1     
+ Partials       2721     2720    -1     
Files with missing lines Coverage Δ
...handler/GlobalTransactionalInterceptorHandler.java 40.48% <100.00%> (+0.29%) ⬆️
...ceptor/handler/AbstractProxyInvocationHandler.java 89.47% <0.00%> (+6.14%) ⬆️

... and 6 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.

@keepConcentration
Copy link
Contributor Author

@YongGoose

Thank you for the earlier feedback 🙏
I have made the following additional changes:

  • Added a unit test (testSetOrderAndSorting) to verify sorting behavior:
    • Creates multiple ProxyInvocationHandler instances with different order values
    • Uses setOrder() to change the order dynamically
    • Asserts both pre-sort and post-sort ordering using the order() method

This should ensure that the ordering logic in AbstractProxyInvocationHandler works as intended.
Please review when you have time — I believe this is now ready for review ✅

@keepConcentration keepConcentration marked this pull request as ready for review August 8, 2025 05:56
@keepConcentration keepConcentration changed the title [WIP] bugfix: fix order() behavior in GlobalTransactionalInterceptorHandler to ensure correct sorting of invocation handlers bugfix: fix order() behavior in GlobalTransactionalInterceptorHandler to ensure correct sorting of invocation handlers Aug 8, 2025
Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

LGTM 🚀
Also, I'd appreciate it if you could revise the parts mentioned in the comments :)

@YongGoose YongGoose requested a review from funky-eyes August 8, 2025 06:13
@YongGoose YongGoose requested a review from Copilot August 8, 2025 06:13
Copy link
Contributor

Copilot AI left a comment

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 fixes the ordering behavior of invocation handlers in the Seata framework by ensuring that the order() method correctly returns the handler's order value for proper sorting. The fix addresses an issue where GlobalTransactionalInterceptorHandler was not being sorted correctly despite having order values set through setOrder() and getOrder() methods.

  • Removed the default implementation of order() method from ProxyInvocationHandler interface, making it abstract
  • Added proper order() method implementations in AbstractProxyInvocationHandler and GlobalTransactionalInterceptorHandler
  • Changed the default order value from Integer.MAX_VALUE to 0 in AbstractProxyInvocationHandler

Reviewed Changes

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

Show a summary per file
File Description
ProxyInvocationHandler.java Removed default order() implementation to make it abstract
AbstractProxyInvocationHandler.java Added order() implementation and changed default order value to 0
GlobalTransactionalInterceptorHandler.java Added order() method implementation
DefaultInterfaceParserTest.java Added comprehensive test cases to verify handler ordering behavior
changes/zh-cn/2.x.md Updated Chinese changelog with fix description
changes/en-us/2.x.md Updated English changelog with fix description

…tx/api/interceptor/handler/AbstractProxyInvocationHandler.java

Co-authored-by: funkye <[email protected]>
@YongGoose
Copy link
Member

@funky-eyes

The TCC transaction propagation test is failing.
Could this be related to this comment?

funky-eyes and others added 2 commits August 10, 2025 22:08
@funky-eyes
Copy link
Contributor

funky-eyes commented Aug 10, 2025

@funky-eyes

The TCC transaction propagation test is failing. Could this be related to this comment?

I think the order of the test cases has changed again, which caused this issue. You can see that the exception started appearing right after this PR was merged: https://github.com/apache/incubator-seata/actions/runs/16847550947/job/47731890204

@YongGoose YongGoose requested a review from funky-eyes August 13, 2025 03:36
Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes
Copy link
Contributor

If you're using the DingTalk app, please send your DingTalk account to my email at [email protected], and I will invite you to join the Seata developer group

@funky-eyes funky-eyes merged commit 1d5c55a into apache:2.x Aug 13, 2025
12 of 14 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
… to ensure correct sorting of invocation handlers (apache#7570)
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
… to ensure correct sorting of invocation handlers (apache#7570)
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 module/intergration-tx-api intergration-tx-api type: bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The order in AbstractProxyInvocationHandler serves no purpose

3 participants