diff options
-rw-r--r-- | .github/workflows/ci-build.yml | 2 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | go.mod | 4 | ||||
-rw-r--r-- | protocol.go | 3 | ||||
-rw-r--r-- | service/container_test.go | 10 | ||||
-rw-r--r-- | service/env/config_test.go | 5 | ||||
-rw-r--r-- | service/gzip/config_test.go | 5 | ||||
-rw-r--r-- | service/gzip/service_test.go | 3 | ||||
-rw-r--r-- | service/headers/config_test.go | 5 | ||||
-rw-r--r-- | service/health/config_test.go | 5 | ||||
-rw-r--r-- | service/health/service_test.go | 3 | ||||
-rw-r--r-- | service/http/config_test.go | 5 | ||||
-rw-r--r-- | service/http/handler_test.go | 8 | ||||
-rw-r--r-- | service/http/request.go | 5 | ||||
-rw-r--r-- | service/http/response.go | 3 | ||||
-rw-r--r-- | service/http/rpc_test.go | 5 | ||||
-rw-r--r-- | service/http/service_test.go | 6 | ||||
-rw-r--r-- | service/http/uploads.go | 3 | ||||
-rw-r--r-- | service/http/uploads_test.go | 3 | ||||
-rw-r--r-- | service/limit/config_test.go | 7 | ||||
-rw-r--r-- | service/limit/service_test.go | 3 | ||||
-rw-r--r-- | service/metrics/config_test.go | 5 | ||||
-rw-r--r-- | service/metrics/service_test.go | 3 | ||||
-rw-r--r-- | service/rpc/config_test.go | 7 | ||||
-rw-r--r-- | service/static/config_test.go | 7 | ||||
-rw-r--r-- | service/static/service_test.go | 6 |
26 files changed, 84 insertions, 38 deletions
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index f308969f..ccba8da0 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -61,7 +61,7 @@ jobs: run: composer analyze - name: Install Go dependencies - run: go mod download + run: go mod download && go mod vendor - name: Download binary roadrunner run: php ./bin/rr get-binary @@ -9,6 +9,7 @@ install: all uninstall: rm -f /usr/local/bin/rr test: + go mod vendor composer update go test -v -race -cover go test -v -race -cover ./util @@ -1,6 +1,6 @@ module github.com/spiral/roadrunner -go 1.13 +go 1.14 require ( github.com/NYTimes/gziphandler v1.1.1 @@ -23,5 +23,5 @@ require ( github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a github.com/yookoala/gofast v0.4.0 golang.org/x/net v0.0.0-20200222125558-5a598a2470a0 - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect ) diff --git a/protocol.go b/protocol.go index 6d2b4c9f..b2836289 100644 --- a/protocol.go +++ b/protocol.go @@ -20,7 +20,8 @@ func sendControl(rl goridge.Relay, v interface{}) error { return rl.Send(data, goridge.PayloadControl|goridge.PayloadRaw) } - data, err := json.Marshal(v) + j := json.ConfigCompatibleWithStandardLibrary + data, err := j.Marshal(v) if err != nil { return fmt.Errorf("invalid payload: %s", err) } diff --git a/service/container_test.go b/service/container_test.go index 1874b355..b3ec7054 100644 --- a/service/container_test.go +++ b/service/container_test.go @@ -67,7 +67,8 @@ type testCfg struct{ cfg string } func (cfg *testCfg) Get(name string) Config { vars := make(map[string]interface{}) - err := json.Unmarshal([]byte(cfg.cfg), &vars) + j := json.ConfigCompatibleWithStandardLibrary + err := j.Unmarshal([]byte(cfg.cfg), &vars) if err != nil { panic("error unmarshalling the cfg.cfg value") } @@ -77,10 +78,13 @@ func (cfg *testCfg) Get(name string) Config { return nil } - d, _ := json.Marshal(v) + d, _ := j.Marshal(v) return &testCfg{cfg: string(d)} } -func (cfg *testCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *testCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} // Config defines RPC service config. type dConfig struct { diff --git a/service/env/config_test.go b/service/env/config_test.go index 2fc12303..a526990d 100644 --- a/service/env/config_test.go +++ b/service/env/config_test.go @@ -10,7 +10,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate(t *testing.T) { cfg := &mockCfg{`{"key":"value"}`} diff --git a/service/gzip/config_test.go b/service/gzip/config_test.go index 1913af64..c2168166 100644 --- a/service/gzip/config_test.go +++ b/service/gzip/config_test.go @@ -10,7 +10,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate(t *testing.T) { cfg := &mockCfg{`{"enable": true}`} diff --git a/service/gzip/service_test.go b/service/gzip/service_test.go index 81c2aed3..778bdacd 100644 --- a/service/gzip/service_test.go +++ b/service/gzip/service_test.go @@ -27,7 +27,8 @@ func (cfg *testCfg) Get(name string) service.Config { return nil } func (cfg *testCfg) Unmarshal(out interface{}) error { - return json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.target), out) } func Test_Disabled(t *testing.T) { diff --git a/service/headers/config_test.go b/service/headers/config_test.go index 994add54..6ea02f67 100644 --- a/service/headers/config_test.go +++ b/service/headers/config_test.go @@ -10,7 +10,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate_Error1(t *testing.T) { cfg := &mockCfg{`{"request": {"From": "Something"}}`} diff --git a/service/health/config_test.go b/service/health/config_test.go index 0b4af817..ba7d7c12 100644 --- a/service/health/config_test.go +++ b/service/health/config_test.go @@ -11,7 +11,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate_Error1(t *testing.T) { cfg := &mockCfg{`{"address": "localhost:8080"}`} diff --git a/service/health/service_test.go b/service/health/service_test.go index f5426434..fc743a62 100644 --- a/service/health/service_test.go +++ b/service/health/service_test.go @@ -33,7 +33,8 @@ func (cfg *testCfg) Get(name string) service.Config { } func (cfg *testCfg) Unmarshal(out interface{}) error { - err := json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + err := j.Unmarshal([]byte(cfg.target), out) return err } diff --git a/service/http/config_test.go b/service/http/config_test.go index 79c81d2d..d95e0995 100644 --- a/service/http/config_test.go +++ b/service/http/config_test.go @@ -13,7 +13,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate_Error1(t *testing.T) { cfg := &mockCfg{`{"address": "localhost:8080"}`} diff --git a/service/http/handler_test.go b/service/http/handler_test.go index 994a663c..cb1cd728 100644 --- a/service/http/handler_test.go +++ b/service/http/handler_test.go @@ -644,7 +644,7 @@ func TestHandler_FormData_POST(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) form := url.Values{} @@ -860,7 +860,7 @@ func TestHandler_FormData_PUT(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) form := url.Values{} @@ -1124,7 +1124,7 @@ func TestHandler_Multipart_PUT(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) var mb bytes.Buffer w := multipart.NewWriter(&mb) @@ -1241,7 +1241,7 @@ func TestHandler_Multipart_PATCH(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) var mb bytes.Buffer w := multipart.NewWriter(&mb) diff --git a/service/http/request.go b/service/http/request.go index d8bd4d30..acf80893 100644 --- a/service/http/request.go +++ b/service/http/request.go @@ -135,12 +135,13 @@ func (r *Request) Close(log *logrus.Logger) { func (r *Request) Payload() (p *roadrunner.Payload, err error) { p = &roadrunner.Payload{} - if p.Context, err = json.Marshal(r); err != nil { + j := json.ConfigCompatibleWithStandardLibrary + if p.Context, err = j.Marshal(r); err != nil { return nil, err } if r.Parsed { - if p.Body, err = json.Marshal(r.body); err != nil { + if p.Body, err = j.Marshal(r.body); err != nil { return nil, err } } else if r.body != nil { diff --git a/service/http/response.go b/service/http/response.go index 38ac4417..0942b3d2 100644 --- a/service/http/response.go +++ b/service/http/response.go @@ -24,7 +24,8 @@ type Response struct { // NewResponse creates new response based on given rr payload. func NewResponse(p *roadrunner.Payload) (*Response, error) { r := &Response{body: p.Body} - if err := json.Unmarshal(p.Context, r); err != nil { + j := json.ConfigCompatibleWithStandardLibrary + if err := j.Unmarshal(p.Context, r); err != nil { return nil, err } diff --git a/service/http/rpc_test.go b/service/http/rpc_test.go index 2874e8b0..9f56e2cd 100644 --- a/service/http/rpc_test.go +++ b/service/http/rpc_test.go @@ -93,10 +93,11 @@ func Test_RPC_Unix(t *testing.T) { c.Register(ID, &Service{}) sock := `unix://` + os.TempDir() + `/rpc.unix` - j, _ := json.Marshal(sock) + j := json.ConfigCompatibleWithStandardLibrary + data, _ := j.Marshal(sock) assert.NoError(t, c.Init(&testCfg{ - rpcCfg: `{"enable":true, "listen":` + string(j) + `}`, + rpcCfg: `{"enable":true, "listen":` + string(data) + `}`, httpCfg: `{ "enable": true, "address": ":6032", diff --git a/service/http/service_test.go b/service/http/service_test.go index 44aba576..53dbb3df 100644 --- a/service/http/service_test.go +++ b/service/http/service_test.go @@ -43,7 +43,8 @@ func (cfg *testCfg) Get(name string) service.Config { return nil } func (cfg *testCfg) Unmarshal(out interface{}) error { - return json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.target), out) } func Test_Service_NoConfig(t *testing.T) { @@ -554,7 +555,8 @@ func Test_Service_Error4(t *testing.T) { func tmpDir() string { p := os.TempDir() - r, _ := json.Marshal(p) + j := json.ConfigCompatibleWithStandardLibrary + r, _ := j.Marshal(p) return string(r) } diff --git a/service/http/uploads.go b/service/http/uploads.go index 15522503..39a9eaf2 100644 --- a/service/http/uploads.go +++ b/service/http/uploads.go @@ -42,7 +42,8 @@ type Uploads struct { // MarshalJSON marshal tree tree into JSON. func (u *Uploads) MarshalJSON() ([]byte, error) { - return json.Marshal(u.tree) + j := json.ConfigCompatibleWithStandardLibrary + return j.Marshal(u.tree) } // Open moves all uploaded files to temp directory, return error in case of issue with temp directory. File errors diff --git a/service/http/uploads_test.go b/service/http/uploads_test.go index f336951e..08177c72 100644 --- a/service/http/uploads_test.go +++ b/service/http/uploads_test.go @@ -424,7 +424,8 @@ func fileString(f string, errNo int, mime string) string { v.Size = 0 } - r, err := json.Marshal(v) + j := json.ConfigCompatibleWithStandardLibrary + r, err := j.Marshal(v) if err != nil { fmt.Println(fmt.Errorf("error marshalling fInfo, error: %v", err)) } diff --git a/service/limit/config_test.go b/service/limit/config_test.go index 72c4bde8..c79836b8 100644 --- a/service/limit/config_test.go +++ b/service/limit/config_test.go @@ -10,8 +10,11 @@ import ( type mockCfg struct{ cfg string } -func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Get(name string) service.Config { return nil } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate_Error1(t *testing.T) { cfg := &mockCfg{`{"enable: true}`} diff --git a/service/limit/service_test.go b/service/limit/service_test.go index eab80af9..5f6ff183 100644 --- a/service/limit/service_test.go +++ b/service/limit/service_test.go @@ -37,7 +37,8 @@ func (cfg *testCfg) Get(name string) service.Config { } func (cfg *testCfg) Unmarshal(out interface{}) error { - err := json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + err := j.Unmarshal([]byte(cfg.target), out) if cl, ok := out.(*Config); ok { // to speed up tests diff --git a/service/metrics/config_test.go b/service/metrics/config_test.go index 4b223905..a64e9047 100644 --- a/service/metrics/config_test.go +++ b/service/metrics/config_test.go @@ -11,7 +11,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate_Error1(t *testing.T) { cfg := &mockCfg{`{"request": {"From": "Something"}}`} diff --git a/service/metrics/service_test.go b/service/metrics/service_test.go index 96289163..cdb81147 100644 --- a/service/metrics/service_test.go +++ b/service/metrics/service_test.go @@ -33,7 +33,8 @@ func (cfg *testCfg) Get(name string) service.Config { } func (cfg *testCfg) Unmarshal(out interface{}) error { - err := json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + err := j.Unmarshal([]byte(cfg.target), out) return err } diff --git a/service/rpc/config_test.go b/service/rpc/config_test.go index d0f26ec6..7a7ca13b 100644 --- a/service/rpc/config_test.go +++ b/service/rpc/config_test.go @@ -10,8 +10,11 @@ import ( type testCfg struct{ cfg string } -func (cfg *testCfg) Get(name string) service.Config { return nil } -func (cfg *testCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *testCfg) Get(name string) service.Config { return nil } +func (cfg *testCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate(t *testing.T) { cfg := &testCfg{`{"enable": true, "listen": "tcp://:18001"}`} diff --git a/service/static/config_test.go b/service/static/config_test.go index 710f9c42..442d87f9 100644 --- a/service/static/config_test.go +++ b/service/static/config_test.go @@ -9,8 +9,11 @@ import ( type mockCfg struct{ cfg string } -func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Get(name string) service.Config { return nil } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate(t *testing.T) { cfg := &mockCfg{`{"dir": "./"}`} diff --git a/service/static/service_test.go b/service/static/service_test.go index b9e44247..1a137cbc 100644 --- a/service/static/service_test.go +++ b/service/static/service_test.go @@ -33,7 +33,8 @@ func (cfg *testCfg) Get(name string) service.Config { return nil } func (cfg *testCfg) Unmarshal(out interface{}) error { - return json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.target), out) } func get(url string) (string, *http.Response, error) { @@ -443,7 +444,8 @@ func Test_Files_NotForbid(t *testing.T) { func tmpDir() string { p := os.TempDir() - r, _ := json.Marshal(p) + j := json.ConfigCompatibleWithStandardLibrary + r, _ := j.Marshal(p) return string(r) } |