diff --git a/pkg/datasource/sql/undo/parser/const.go b/pkg/datasource/sql/undo/parser/const.go index c1477d826..d219b4b24 100644 --- a/pkg/datasource/sql/undo/parser/const.go +++ b/pkg/datasource/sql/undo/parser/const.go @@ -18,5 +18,5 @@ package parser const ( - DefaultSerializer = "jackson" + DefaultSerializer = "json" ) diff --git a/pkg/datasource/sql/undo/parser/parser_cache.go b/pkg/datasource/sql/undo/parser/parser_cache.go index f8719ab04..511fd093a 100644 --- a/pkg/datasource/sql/undo/parser/parser_cache.go +++ b/pkg/datasource/sql/undo/parser/parser_cache.go @@ -38,7 +38,7 @@ func initCache() { serializerNameToParser: make(map[string]UndoLogParser, 0), } - cache.store(&JacksonParser{}) + cache.store(&JsonParser{}) } func GetCache() *UndoLogParserCache { diff --git a/pkg/datasource/sql/undo/parser/parser_cache_test.go b/pkg/datasource/sql/undo/parser/parser_cache_test.go index 55b9b8739..a1b80918f 100644 --- a/pkg/datasource/sql/undo/parser/parser_cache_test.go +++ b/pkg/datasource/sql/undo/parser/parser_cache_test.go @@ -41,7 +41,7 @@ func TestGetDefault(t *testing.T) { } func TestLoad(t *testing.T) { - jacksonParser, err := GetCache().Load("jackson") + jsonParser, err := GetCache().Load("json") assert.Nil(t, err) - assert.NotNil(t, jacksonParser) + assert.NotNil(t, jsonParser) } diff --git a/pkg/datasource/sql/undo/parser/parser_jackson.go b/pkg/datasource/sql/undo/parser/parser_json.go similarity index 83% rename from pkg/datasource/sql/undo/parser/parser_jackson.go rename to pkg/datasource/sql/undo/parser/parser_json.go index 57ea45c1a..e736358bb 100644 --- a/pkg/datasource/sql/undo/parser/parser_jackson.go +++ b/pkg/datasource/sql/undo/parser/parser_json.go @@ -23,25 +23,25 @@ import ( "github.com/seata/seata-go/pkg/datasource/sql/undo" ) -type JacksonParser struct { +type JsonParser struct { } // Get the name of parser; // return the name of parser -func (j *JacksonParser) GetName() string { - return "jackson" +func (j *JsonParser) GetName() string { + return "json" } // Get default context of this parser // return the default content if undo log is empty -func (j *JacksonParser) GetDefaultContent() []byte { +func (j *JsonParser) GetDefaultContent() []byte { return []byte("{}") } // Encode branch undo log to byte array. // param branchUndoLog the branch undo log // return the byte array -func (j *JacksonParser) Encode(branchUndoLog *undo.BranchUndoLog) ([]byte, error) { +func (j *JsonParser) Encode(branchUndoLog *undo.BranchUndoLog) ([]byte, error) { bytes, err := json.Marshal(branchUndoLog) if err != nil { return nil, err @@ -53,7 +53,7 @@ func (j *JacksonParser) Encode(branchUndoLog *undo.BranchUndoLog) ([]byte, error // Decode byte array to branch undo log. // param bytes the byte array // return the branch undo log -func (j *JacksonParser) Decode(bytes []byte) (*undo.BranchUndoLog, error) { +func (j *JsonParser) Decode(bytes []byte) (*undo.BranchUndoLog, error) { var branchUndoLog *undo.BranchUndoLog if err := json.Unmarshal(bytes, &branchUndoLog); err != nil { return nil, err diff --git a/pkg/datasource/sql/undo/parser/parser_jackson_test.go b/pkg/datasource/sql/undo/parser/parser_json_test.go similarity index 92% rename from pkg/datasource/sql/undo/parser/parser_jackson_test.go rename to pkg/datasource/sql/undo/parser/parser_json_test.go index 1ae5defb1..4829af76e 100644 --- a/pkg/datasource/sql/undo/parser/parser_jackson_test.go +++ b/pkg/datasource/sql/undo/parser/parser_json_test.go @@ -25,11 +25,11 @@ import ( ) func TestGetName(t *testing.T) { - assert.Equal(t, "jackson", (&JacksonParser{}).GetName()) + assert.Equal(t, "json", (&JsonParser{}).GetName()) } func TestGetDefaultContext(t *testing.T) { - assert.Equal(t, []byte("{}"), (&JacksonParser{}).GetDefaultContent()) + assert.Equal(t, []byte("{}"), (&JsonParser{}).GetDefaultContent()) } func TestEncode(t *testing.T) { @@ -53,7 +53,7 @@ func TestEncode(t *testing.T) { for _, Case := range TestCases { t.Run(Case.CaseName, func(t *testing.T) { - logParser := &JacksonParser{} + logParser := &JsonParser{} bytes, err := logParser.Encode(Case.UndoLog) if Case.ExpectErr { assert.NotNil(t, err) @@ -87,7 +87,7 @@ func TestDecode(t *testing.T) { for _, Case := range TestCases { t.Run(Case.CaseName, func(t *testing.T) { - logParser := &JacksonParser{} + logParser := &JsonParser{} undoLog, err := logParser.Decode([]byte(Case.InputBytes)) if Case.ExpectErr { assert.NotNil(t, err)