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: java exception & typed list support for hessian #120

Merged
merged 3 commits into from
Jul 4, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: java exception & unit test
  • Loading branch information
wongoo committed Jul 4, 2019
commit 52ad4e6c52db536bd980de3daa8bc771cc19afd8
3 changes: 2 additions & 1 deletion examples/dubbo/go-server/app/user.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ package main
import (
"context"
"fmt"
"github.com/dubbogo/hessian2/java_exception"
"strconv"
"time"
)
@@ -172,7 +173,7 @@ func (u *UserProvider) GetUser3() error {
}

func (u *UserProvider) GetErr(ctx context.Context, req []interface{}, rsp *User) error {
return hessian.NewThrowable("exception")
return java_exception.NewThrowable("exception")
}

func (u *UserProvider) GetUsers(req []interface{}) ([]interface{}, error) {
3 changes: 2 additions & 1 deletion examples/dubbo/with-configcenter-go-server/app/user.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ package main
import (
"context"
"fmt"
"github.com/dubbogo/hessian2/java_exception"
"strconv"
"time"
)
@@ -146,7 +147,7 @@ func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User
}

func (u *UserProvider) GetErr(ctx context.Context, req []interface{}, rsp *User) error {
return hessian.NewThrowable("exception")
return java_exception.NewThrowable("exception")
}

func (u *UserProvider) GetUser0(id string, name string) (User, error) {
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ module github.com/apache/dubbo-go
require (
github.com/dubbogo/getty v1.0.7
github.com/dubbogo/gost v1.0.0
github.com/dubbogo/hessian2 v1.1.1
github.com/dubbogo/hessian2 v1.1.2
github.com/magiconair/properties v1.8.1
github.com/pkg/errors v0.8.1
github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ github.com/dubbogo/getty v1.0.7 h1:5Hg+JwXyCKm9Yr4yJkm98ahhnoa8c2h6br5QJxwQ+YU=
github.com/dubbogo/getty v1.0.7/go.mod h1:cRMSuoCmwc5lULFFnYZTxyCfZhObmRTNbS7XRnPNHSo=
github.com/dubbogo/gost v1.0.0 h1:obKvpJYdrIY2BidHYwYoj2E50OtwCDqVVVTcH2nnhAY=
github.com/dubbogo/gost v1.0.0/go.mod h1:R7wZm1DrmrKGr50mBZVcg6C9ekG8aL5hP+sgWcIDwQg=
github.com/dubbogo/hessian2 v1.1.1 h1:X8UlNUvn/lqct2GKY37MFGnZ2f51HRndAQHk6+RMtqc=
github.com/dubbogo/hessian2 v1.1.1/go.mod h1:XFGDn4oSZX26zkcfhkM/fCJrOqwQJxk/xgWW1KMJBKM=
github.com/dubbogo/hessian2 v1.1.2 h1:SRkPzIwVv2D+ZUOCE2XuI5kANoL01ShhAheLcc3usJE=
github.com/dubbogo/hessian2 v1.1.2/go.mod h1:XFGDn4oSZX26zkcfhkM/fCJrOqwQJxk/xgWW1KMJBKM=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
1 change: 0 additions & 1 deletion protocol/dubbo/client.go
Original file line number Diff line number Diff line change
@@ -217,7 +217,6 @@ func (c *Client) call(ct CallType, addr string, svcUrl common.URL, method string

p := &DubboPackage{}
p.Service.Path = strings.TrimPrefix(svcUrl.Path, "/")
p.Service.Target = svcUrl.GetParam(constant.INTERFACE_KEY, "")
p.Service.Interface = svcUrl.GetParam(constant.INTERFACE_KEY, "")
p.Service.Version = svcUrl.GetParam(constant.VERSION_KEY, "")
p.Service.Method = method
5 changes: 2 additions & 3 deletions protocol/dubbo/codec_test.go
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@ func TestDubboPackage_MarshalAndUnmarshal(t *testing.T) {
// request
pkg.Header.Type = hessian.PackageRequest
pkg.Service.Interface = "Service"
pkg.Service.Target = "Service"
pkg.Service.Version = "2.6"
pkg.Service.Method = "Method"
pkg.Service.Timeout = time.Second
@@ -64,10 +63,10 @@ func TestDubboPackage_MarshalAndUnmarshal(t *testing.T) {
assert.Equal(t, byte(S_Dubbo), pkgres.Header.SerialID)
assert.Equal(t, int64(10086), pkgres.Header.ID)
assert.Equal(t, "2.5.4", pkgres.Body.([]interface{})[0])
assert.Equal(t, "Service", pkgres.Body.([]interface{})[1])
assert.Equal(t, "", pkgres.Body.([]interface{})[1])
assert.Equal(t, "2.6", pkgres.Body.([]interface{})[2])
assert.Equal(t, "Method", pkgres.Body.([]interface{})[3])
assert.Equal(t, "Ljava/lang/String;", pkgres.Body.([]interface{})[4])
assert.Equal(t, []interface{}{"a"}, pkgres.Body.([]interface{})[5])
assert.Equal(t, map[interface{}]interface{}{"interface": "Service", "path": "", "timeout": "1000"}, pkgres.Body.([]interface{})[6])
assert.Equal(t, map[interface{}]interface{}{"interface": "Service", "path": "", "group": "", "timeout": "1000"}, pkgres.Body.([]interface{})[6])
}