Skip to content

Commit

Permalink
Merge 0865622 into b5cd555
Browse files Browse the repository at this point in the history
  • Loading branch information
justxuewei authored Jun 4, 2021
2 parents b5cd555 + 0865622 commit 0ab2502
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
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

0 comments on commit 0ab2502

Please sign in to comment.