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: URL serialization bug #1238

Merged
merged 3 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ type URL struct {
SubURL *URL
}

// JavaClassName POJO for URL
func (c *URL) JavaClassName() string {
return "org.apache.dubbo.common.URL"
}

// Option accepts URL
// Option will define a function of handling URL
type Option func(*URL)
Expand Down
37 changes: 28 additions & 9 deletions protocol/dubbo/hessian2/hessian_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,49 @@ func packResponse(header DubboHeader, ret interface{}) ([]byte, error) {
}

if response.Exception != nil { // throw error
_ = encoder.Encode(resWithException)
err := encoder.Encode(resWithException)
if err != nil {
return nil, perrors.Errorf("encoding response failed: %v", err)
}
if t, ok := response.Exception.(java_exception.Throwabler); ok {
_ = encoder.Encode(t)
err = encoder.Encode(t)
} else {
_ = encoder.Encode(java_exception.NewThrowable(response.Exception.Error()))
err = encoder.Encode(java_exception.NewThrowable(response.Exception.Error()))
}
if err != nil {
return nil, perrors.Errorf("encoding exception failed: %v", err)
}
} else {
if response.RspObj == nil {
_ = encoder.Encode(resNullValue)
if err := encoder.Encode(resNullValue); err != nil {
return nil, perrors.Errorf("encoding null value failed: %v", err)
}
} else {
_ = encoder.Encode(resValue)
_ = encoder.Encode(response.RspObj) // result
if err := encoder.Encode(resValue); err != nil {
return nil, perrors.Errorf("encoding response value failed: %v", err)
}
if err := encoder.Encode(response.RspObj); err != nil {
return nil, perrors.Errorf("encoding response failed: %v", err)
}
}
}

// attachments
if atta {
_ = encoder.Encode(response.Attachments) // attachments
if err := encoder.Encode(response.Attachments); err != nil {
return nil, perrors.Errorf("encoding response attachements failed: %v", err)
}
}
}
} else {
var err error
if response.Exception != nil { // throw error
_ = encoder.Encode(response.Exception.Error())
err = encoder.Encode(response.Exception.Error())
} else {
_ = encoder.Encode(response.RspObj)
err = encoder.Encode(response.RspObj)
}
if err != nil {
return nil, perrors.Errorf("encoding error failed: %v", err)
}
}

Expand Down