apache / dubbo-go

Go Implementation For Apache Dubbo .
https://dubbo.apache.org/
Apache License 2.0
4.67k stars 910 forks source link

Compatibility/java interop #2687

Closed SHA-4096 closed 1 week ago

SHA-4096 commented 1 month ago

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 https://github.com/apache/dubbo-go-samples/pull/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

sonarcloud[bot] commented 1 month ago

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 commented 1 month ago

Please run make fmt to format the code