Skip to content
Permalink
Browse files
Merge pull request #303 from alpha-baby/issue299
reproduce decode interface map bug #299
  • Loading branch information
AlexStocks committed Dec 30, 2021
2 parents 0b16449 + a36dcbf commit 1f4cc010dcfba0a77c2eae2bf33b37a6976bcd45
Showing 2 changed files with 14 additions and 5 deletions.
@@ -201,7 +201,8 @@ func (Issue299Args1) JavaClassName() string {
}

type Issue299MockData struct {
Args []interface{}
SliceArgs []interface{}
MapArgs map[string]interface{}
}

func (Issue299MockData) JavaClassName() string {
@@ -213,11 +214,19 @@ func TestIssue299HessianDecode(t *testing.T) {
RegisterPOJO(new(Issue299MockData))

d := &Issue299MockData{
Args: []interface{}{
SliceArgs: []interface{}{
[]*Issue299Args1{
{Label: "1", Key: "2"},
},
},
MapArgs: map[string]interface{}{
"interface_slice": []interface{}{
"MyName",
},
"interface_map": map[interface{}]interface{}{
"k1": "v1",
},
},
}

encoder := NewEncoder()
@@ -234,7 +243,7 @@ func TestIssue299HessianDecode(t *testing.T) {
}
do := doInterface.(*Issue299MockData)
if !reflect.DeepEqual(d, do) {
t.Errorf("not equal d: %+v, do: %+v", d, do)
t.Errorf("not equal d: %#v, do: %#v", d, do)
return
}
}
4 map.go
@@ -206,8 +206,8 @@ func (d *Decoder) decMapByValue(value reflect.Value) error {
if err != nil {
return perrors.WithStack(err)
}
// TODO map value may be a ref object
m.Elem().SetMapIndex(EnsurePackValue(entryKey), EnsurePackValue(entryValue))

m.Elem().SetMapIndex(EnsurePackValue(entryKey), EnsureRawValue(entryValue))
}

SetValue(value, m)

0 comments on commit 1f4cc01

Please sign in to comment.