Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ggwhite/go-hessian
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: LeakIX/go-hessian
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Aug 24, 2023

  1. Handle deserialize panic

    gboddin committed Aug 24, 2023
    Copy the full SHA
    ced7962 View commit details
Showing with 16 additions and 7 deletions.
  1. +2 −1 .gitignore
  2. +2 −2 README.md
  3. +3 −0 go.mod
  4. +8 −3 proxy.go
  5. +1 −1 test/main.go
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage.txt
coverage.txt
.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Golang Hessian
# Golang Hessian

[![Build Status](https://travis-ci.org/ggwhite/go-hessian.svg?branch=master)](https://travis-ci.org/ggwhite/go-hessian)
[![codecov](https://codecov.io/gh/ggwhite/go-hessian/branch/master/graph/badge.svg)](https://codecov.io/gh/ggwhite/go-hessian)
@@ -152,4 +152,4 @@ Result:
|list |Y |Y |V type? length? object* z |
|map |Y |Y |M t b16 b8 type-string (object, object)* z |
|ref |N |N | |
|remote |N |N | |
|remote |N |N | |
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/LeakIX/go-hessian

go 1.20
11 changes: 8 additions & 3 deletions proxy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hessian

import (
"errors"
"fmt"
"log"
"net/http"
@@ -49,7 +50,7 @@ type Proxy struct {
}

// Invoke input method name and arguments, it will send request to server, and parse response to interface
func (c *Proxy) Invoke(m string, args ...interface{}) ([]interface{}, error) {
func (c *Proxy) Invoke(m string, args ...interface{}) (_ []interface{}, err error) {

c.serializer.Flush()

@@ -76,12 +77,16 @@ func (c *Proxy) Invoke(m string, args ...interface{}) ([]interface{}, error) {
}

c.deserializer.Reset(resp.Body)

// Set the default error return value
err = errors.New("deserialize failed")
defer func() {
// Recover on read issues
_ = recover()
}()
ans, err := c.deserializer.Read()
if err != nil {
return nil, err
}

return ans, nil
}

2 changes: 1 addition & 1 deletion test/main.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"reflect"
"time"

hessian "github.com/ggwhite/go-hessian"
hessian "github.com/LeakIX/go-hessian"
)

type User struct {