Skip to content

Compatibility/java interop #2687

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

Merged
merged 6 commits into from
Jul 6, 2024

Conversation

SHA-4096
Copy link
Contributor

@SHA-4096 SHA-4096 commented Jun 13, 2024

What's the purpose of the change

1. handler mismatch

When interoperating with dubbo-java, there may be an issue when client from java side try to invoke an rpc function whose first-letter is in lower case, since dubbo-go now only provide handler whose method name is always with upper-cased first letter, due to the language feature of golang. It would cause failure in rpc function invocation, as mentioned in apache/dubbo-go-samples#771 .

To tackle this problem, a straightforward idea is to register another handler with a different first-letter case, and that's the change made by this pull request.

2. content-type codec mismatch

When using hessian2 for serialization, some version of java-side client would set a wrong content-type in request, causing marshal and unmarshal error. In order to tackle the problem, a backupCodec is introduced to handle the message in the server-side serialization type.

Validity of the solution

solution for problem 1

After adding a breakpoint at dubbo-go/server/server.go at line 254, which is the section that exports service , we can see the registered handlers on service->serviceOpts->rpsService->s->triServer->handlers, and /org.apache.dubbo.tri.hessian2.api.GreetingsService/greet is made possible by changes in this PR.
image

solution for problem 2

A warn message would be logged when request content-type and server serialization mismatches, and the server would try to marshal/unmarshal message in server serialization codec.
image

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
1.1% Duplication on New Code

See analysis details on SonarCloud

@chickenlj
Copy link
Contributor

Please run make fmt to format the code

@@ -0,0 +1,18 @@
package dubboutil
Copy link
Contributor

Choose a reason for hiding this comment

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

Add apache license header for this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@@ -19,6 +19,7 @@ package common

import (
"context"
"dubbo.apache.org/dubbo-go/v3/common/dubboutil"
Copy link
Contributor

Choose a reason for hiding this comment

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

pls format imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

formatted

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.

@chickenlj chickenlj merged commit 69511b2 into apache:main Jul 6, 2024
3 of 4 checks passed
@SHA-4096 SHA-4096 mentioned this pull request Jul 8, 2024
2 tasks
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.

3 participants