Skip to content

Releases: apache/dubbo-go-hessian2

v1.11.2

24 Oct 03:26
Compare
Choose a tag to compare

Bugfixes

  • fix java enum variable list decoding error. #330
  • fix ref list is nil when decoding. #324

v1.11.1

22 Jul 10:57
Compare
Choose a tag to compare

Bugfixes

  • fix not writing class name first when encoding pojo map. #320
  • fix nil slice decoding to empty slice. #318

v1.11.0

19 Jan 00:50
Compare
Choose a tag to compare

New Features

  • support encode object to map and vice versa. #309

The following example shows how that works:

person := Person{
	Age:      18,
	Sex:      true,
}

worker1 := &Worker{
	Person: person,
	CurJob: JOB{Title: "cto", Company: "facebook"},
	Jobs: []JOB{
		{Title: "manager", Company: "google"},
		{Title: "ceo", Company: "microsoft"},
	},
}

e := NewEncoder()
err := e.Encode(worker1)
if err != nil {
	t.Error(err)
	t.FailNow()
}
data := e.Buffer()

// unRegisterPOJO before decode, so that to decode to map
unRegisterPOJO(person)
unRegisterPOJO(worker1)
unRegisterPOJO(&worker1.Jobs[0])

// strict mode
d := NewDecoder(data)
d.Strict = true // set to strict mode, then the decoding will return error for class not being registered.
res, err := d.Decode()
if err == nil {
	t.Error("after unregister pojo, decoding should return error for strict mode")
	t.FailNow()
}

// non-strict mode, decode to map for class not being registered.
d = NewDecoder(data)
res, err = d.Decode()
if err != nil {
	t.Error(err)
	t.FailNow()
}

worker2, ok := res.(map[string]interface{}) // the response is a map
if !ok {
	t.Fatalf("res:%#v should be a map for non-strict mode", res)
}

// encode the map to object again, note the worker2 is a map.
e = NewEncoder()
err = e.Encode(worker2)
if err != nil {
	t.Error(err)
	t.FailNow()
}

data = e.Buffer()

// register pojo again, so that there are class definitions, which are used to encode map to object.
RegisterPOJO(person)
RegisterPOJO(worker1)
RegisterPOJO(&worker1.Jobs[0])

// decode the encoded map data to struct object.
d = NewDecoder(data)
res, err = d.Decode()
if err != nil {
	t.Error(err)
	t.FailNow()
}

worker3, ok := res.(*Worker) // worker3 is a Worker
if !ok {
	t.Fatalf("res:%#v should be a worker type", res)
}

if !reflect.DeepEqual(worker1, worker3) {
	t.Fatal("worker1 not equal to worker3!")
}

v1.10.3

17 Jan 09:11
Compare
Choose a tag to compare

New Features

  • add a tool for generate hessian2 java enum define golang code. #304

Bugfixes

  • fix decode interface map bug. #303
  • fix decode bool error. #302

v1.10.2

24 Dec 06:44
Compare
Choose a tag to compare

Bugfixes

  • fix list value not unpacked. #300

v1.10.1

21 Dec 03:26
Compare
Choose a tag to compare

Bugfixes

  • support java integer null. #296
  • fix parse basic type bug. #298

v1.10.0

03 Dec 16:10
Compare
Choose a tag to compare

New Features

  • support java function param type. #295

v1.9.5

18 Nov 09:03
Compare
Choose a tag to compare

v1.9.5

New Features

  • support serialize UUID to string. #285
  • support encode non-pointer instance for pointer POJO definition. #289

Bugfixes

  • fix POJO registration. #287
  • fix EOF error check. #288
  • fix go type name for list. #290

v1.9.4

19 Oct 09:51
Compare
Choose a tag to compare

New Features

  • support wrapper classes for Java basic types. #278

Bugfixes

  • fix registration ignored for struct with same name in diff package. #279
  • fix cannot encode pointer of raw type. #283

v1.9.3

08 Sep 02:11
Compare
Choose a tag to compare

New Features

  • add new api Encoder.ReuseBufferClean(). #271

Bugfixes

  • fix not unpack ref holder for list. #269
  • fix encode null for empty map, add map tag instead. #275
  • Fix getArgType reflection value logic. #276