Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ClassCastException caused by 2.x's filter in some condition #12286

Merged
merged 9 commits into from May 17, 2023

Conversation

wegod
Copy link
Contributor

@wegod wegod commented May 10, 2023

What is the purpose of the change

When upgrading from dubbo 2.x to 3.x, we have many projects and need to call provider service using 2.x filter and return RpcResult in some case.
So it's better to compatible of RpcResult when 3.x consumer calling 2.x provider

Brief changelog

Fix ClassCastException caused by 2.x's filter in some condition and compatible of RpcResult in dubbo version 2.x

Verifying this change

I test on my local env

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

Comment on lines 35 to 38
@Override
public org.apache.dubbo.rpc.Result whenCompleteWithContext(BiConsumer<org.apache.dubbo.rpc.Result, Throwable> fn) {
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of adding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait a moment, I found when dubbo3 using dubbo2's Filter, RpcResult will be handle as AsyncRpcResult.
This function whenCompleteWithContext will be changed later, more code need to fix.

@AlbumenJ
Copy link
Member

@wegod I have try to help you fix the test cases :)

@AlbumenJ AlbumenJ changed the base branch from 3.1 to 3.2 May 16, 2023 03:54
@codecov-commenter
Copy link

codecov-commenter commented May 16, 2023

Codecov Report

Merging #12286 (0b7bb7b) into 3.2 (cbc2040) will increase coverage by 0.03%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                3.2   #12286      +/-   ##
============================================
+ Coverage     69.35%   69.38%   +0.03%     
  Complexity        2        2              
============================================
  Files          1606     1606              
  Lines         66229    66229              
  Branches       9718     9718              
============================================
+ Hits          45932    45953      +21     
+ Misses        15851    15831      -20     
+ Partials       4446     4445       -1     

see 32 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@wegod
Copy link
Contributor Author

wegod commented May 16, 2023

@wegod I have try to help you fix the test cases :)

Thanks very much.
Right now I'm using 3.1.10. Will this branch merge into 3.1.11 or 12?

wegod added 2 commits May 16, 2023 16:37
When DubboProtocol.CompletableFuture running result.thenApply and  FilterChainBuilder.CallbackRegistrationInvoker running asyncResult.whenCompleteWithContext. All Result handle as AsyncRpcResult, so RpcResult add some methods implements seems like AsyncRpcResult does.
@wegod
Copy link
Contributor Author

wegod commented May 16, 2023

@AlbumenJ My test is done, I found new change in Filter.java and CompatibleResult.java that's better than my first code change.
All case works in both provider side and consumer side, no matter dubbo2.x or 3.x is provider or consumer.

@sonarcloud
Copy link

sonarcloud bot commented May 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

75.0% 75.0% Coverage
0.0% 0.0% Duplication

@chickenlj chickenlj self-requested a review May 17, 2023 02:27
@AlbumenJ
Copy link
Member

@wegod I have try to help you fix the test cases :)

Thanks very much. Right now I'm using 3.1.10. Will this branch merge into 3.1.11 or 12?

According to the roadmap, 3.1.x is only for security fix now. We can only maintian one branch due to limited working time (:

Copy link
Contributor

@chickenlj chickenlj left a comment

Choose a reason for hiding this comment

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

LGTM.

@AlbumenJ AlbumenJ merged commit 35a6365 into apache:3.2 May 17, 2023
14 checks passed
@wegod
Copy link
Contributor Author

wegod commented May 17, 2023

@wegod I have try to help you fix the test cases :)

Thanks very much. Right now I'm using 3.1.10. Will this branch merge into 3.1.11 or 12?

According to the roadmap, 3.1.x is only for security fix now. We can only maintian one branch due to limited working time (:

All right. I'll upgrade to 3.2.x when it's stable.

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.

None yet

4 participants