Skip to content

Commit

Permalink
feat: compatibility with lower-cased first-letter java class name
Browse files Browse the repository at this point in the history
  • Loading branch information
SHA-4096 committed Jun 13, 2024
1 parent 872d8ed commit f3eff3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/rpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func suitableMethods(typ reflect.Type) (string, map[string]*MethodType) {
//For better interoperability with java class,
//we convert the first letter in methodName between
//upper and lower case
methods[dubboutil.SwapCaseFirstRune(methodName)] = mt
mts = append(mts, dubboutil.SwapCaseFirstRune(methodName))
}
}
Expand Down
13 changes: 13 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

import (
"dubbo.apache.org/dubbo-go/v3/common"
dubboutil "dubbo.apache.org/dubbo-go/v3/common/dubboutil"
"dubbo.apache.org/dubbo-go/v3/metadata"
"dubbo.apache.org/dubbo-go/v3/protocol"
registry_exposed "dubbo.apache.org/dubbo-go/v3/registry/exposed_tmp"
Expand Down Expand Up @@ -180,6 +181,18 @@ func (s *Server) exportServices() (err error) {
err = svcOpts.ExportWithoutInfo()
} else {
info := infoRaw.(*ServiceInfo)
//Add a method with a name of a differtent first-letter case
//to achieve interoperability with java
var additionalMethods []MethodInfo
for _, method := range info.Methods {
newMethod := method
newMethod.Name = dubboutil.SwapCaseFirstRune(method.Name)
additionalMethods = append(additionalMethods, newMethod)
}
for _, additionalMethod := range additionalMethods {
info.Methods = append(info.Methods, additionalMethod)
}

err = svcOpts.ExportWithInfo(info)
}
if err != nil {
Expand Down

0 comments on commit f3eff3b

Please sign in to comment.