summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci-build.yml2
-rw-r--r--Makefile1
-rw-r--r--go.mod5
-rw-r--r--go.sum3
-rw-r--r--protocol.go5
-rw-r--r--service/container_test.go12
-rw-r--r--service/env/config_test.go7
-rw-r--r--service/gzip/config_test.go7
-rw-r--r--service/gzip/service_test.go5
-rw-r--r--service/headers/config_test.go7
-rw-r--r--service/headers/service_test.go2
-rw-r--r--service/health/config_test.go7
-rw-r--r--service/health/service_test.go5
-rw-r--r--service/http/config_test.go7
-rw-r--r--service/http/handler_test.go8
-rw-r--r--service/http/request.go7
-rw-r--r--service/http/response.go5
-rw-r--r--service/http/rpc_test.go7
-rw-r--r--service/http/service_test.go8
-rw-r--r--service/http/uploads.go5
-rw-r--r--service/http/uploads_test.go5
-rw-r--r--service/limit/config_test.go9
-rw-r--r--service/limit/service_test.go5
-rw-r--r--service/metrics/config_test.go7
-rw-r--r--service/metrics/service_test.go5
-rw-r--r--service/rpc/config_test.go9
-rw-r--r--service/static/config_test.go9
-rw-r--r--service/static/service_test.go8
28 files changed, 112 insertions, 60 deletions
diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml
index f308969f..7bf9c77e 100644
--- a/.github/workflows/ci-build.yml
+++ b/.github/workflows/ci-build.yml
@@ -68,6 +68,8 @@ jobs:
- name: Run golang tests
run: |
+ go mod vendor
+ composer update
go test -race -v -coverprofile=lib.txt -covermode=atomic
go test ./util -race -v -coverprofile=util.txt -covermode=atomic
go test ./service -race -v -coverprofile=service.txt -covermode=atomic
diff --git a/Makefile b/Makefile
index d7e85f90..f1a0fa55 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/go.mod b/go.mod
index 988a9856..2fdacaf5 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/spiral/roadrunner
-go 1.13
+go 1.14
require (
github.com/NYTimes/gziphandler v1.1.1
@@ -8,6 +8,7 @@ require (
github.com/buger/goterm v0.0.0-20181115115552-c206103e1f37
github.com/dustin/go-humanize v1.0.0
github.com/go-ole/go-ole v1.2.4 // indirect
+ github.com/json-iterator/go v1.1.9
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/olekukonko/tablewriter v0.0.4
@@ -22,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/go.sum b/go.sum
index 183fa45e..3226302a 100644
--- a/go.sum
+++ b/go.sum
@@ -94,6 +94,7 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5i
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
@@ -136,8 +137,10 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
diff --git a/protocol.go b/protocol.go
index 42649264..b2836289 100644
--- a/protocol.go
+++ b/protocol.go
@@ -1,8 +1,8 @@
package roadrunner
import (
- "encoding/json"
"fmt"
+ json "github.com/json-iterator/go"
"github.com/spiral/goridge"
"os"
)
@@ -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 d7ca73a7..b3ec7054 100644
--- a/service/container_test.go
+++ b/service/container_test.go
@@ -1,8 +1,8 @@
package service
import (
- "encoding/json"
"errors"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert"
@@ -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 226712c3..a526990d 100644
--- a/service/env/config_test.go
+++ b/service/env/config_test.go
@@ -1,7 +1,7 @@
package env
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
"testing"
@@ -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 92bb1cb5..c2168166 100644
--- a/service/gzip/config_test.go
+++ b/service/gzip/config_test.go
@@ -1,7 +1,7 @@
package gzip
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
"testing"
@@ -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 9a62a08b..778bdacd 100644
--- a/service/gzip/service_test.go
+++ b/service/gzip/service_test.go
@@ -1,7 +1,7 @@
package gzip
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner/service"
@@ -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 e6b9b8ff..6ea02f67 100644
--- a/service/headers/config_test.go
+++ b/service/headers/config_test.go
@@ -1,7 +1,7 @@
package headers
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
"testing"
@@ -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/headers/service_test.go b/service/headers/service_test.go
index 120bb3d6..e4bbfb84 100644
--- a/service/headers/service_test.go
+++ b/service/headers/service_test.go
@@ -1,7 +1,7 @@
package headers
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner/service"
diff --git a/service/health/config_test.go b/service/health/config_test.go
index 9068f2ca..ba7d7c12 100644
--- a/service/health/config_test.go
+++ b/service/health/config_test.go
@@ -1,7 +1,7 @@
package health
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"testing"
"github.com/spiral/roadrunner/service"
@@ -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 e8685548..fc743a62 100644
--- a/service/health/service_test.go
+++ b/service/health/service_test.go
@@ -1,7 +1,7 @@
package health
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"io/ioutil"
"net/http"
"testing"
@@ -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 d8b92247..d95e0995 100644
--- a/service/http/config_test.go
+++ b/service/http/config_test.go
@@ -1,7 +1,7 @@
package http
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
@@ -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 630e26f6..acf80893 100644
--- a/service/http/request.go
+++ b/service/http/request.go
@@ -1,8 +1,8 @@
package http
import (
- "encoding/json"
"fmt"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/spiral/roadrunner"
"github.com/spiral/roadrunner/service/http/attributes"
@@ -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 16434a7c..0942b3d2 100644
--- a/service/http/response.go
+++ b/service/http/response.go
@@ -1,7 +1,7 @@
package http
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"io"
"net/http"
"strings"
@@ -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 c73f2a91..9f56e2cd 100644
--- a/service/http/rpc_test.go
+++ b/service/http/rpc_test.go
@@ -1,7 +1,7 @@
package http
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner/service"
@@ -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 1d8af9c0..53dbb3df 100644
--- a/service/http/service_test.go
+++ b/service/http/service_test.go
@@ -1,7 +1,7 @@
package http
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner"
@@ -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 8a46f230..39a9eaf2 100644
--- a/service/http/uploads.go
+++ b/service/http/uploads.go
@@ -1,8 +1,8 @@
package http
import (
- "encoding/json"
"fmt"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"io"
"io/ioutil"
@@ -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 1890c02b..08177c72 100644
--- a/service/http/uploads_test.go
+++ b/service/http/uploads_test.go
@@ -5,8 +5,8 @@ import (
"context"
"crypto/md5"
"encoding/hex"
- "encoding/json"
"fmt"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner"
"github.com/stretchr/testify/assert"
"io"
@@ -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 b388791f..c79836b8 100644
--- a/service/limit/config_test.go
+++ b/service/limit/config_test.go
@@ -1,7 +1,7 @@
package limit
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
"testing"
@@ -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 abc03e69..5f6ff183 100644
--- a/service/limit/service_test.go
+++ b/service/limit/service_test.go
@@ -1,8 +1,8 @@
package limit
import (
- "encoding/json"
"fmt"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner/service"
@@ -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 ad60102b..a64e9047 100644
--- a/service/metrics/config_test.go
+++ b/service/metrics/config_test.go
@@ -1,7 +1,7 @@
package metrics
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
@@ -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 62e6f6d7..cdb81147 100644
--- a/service/metrics/service_test.go
+++ b/service/metrics/service_test.go
@@ -1,7 +1,7 @@
package metrics
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
@@ -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 623347ed..7a7ca13b 100644
--- a/service/rpc/config_test.go
+++ b/service/rpc/config_test.go
@@ -1,7 +1,7 @@
package rpc
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
"runtime"
@@ -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 0221e116..442d87f9 100644
--- a/service/static/config_test.go
+++ b/service/static/config_test.go
@@ -1,7 +1,7 @@
package static
import (
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
"testing"
@@ -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 bd929214..1a137cbc 100644
--- a/service/static/service_test.go
+++ b/service/static/service_test.go
@@ -2,7 +2,7 @@ package static
import (
"bytes"
- "encoding/json"
+ json "github.com/json-iterator/go"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner/service"
@@ -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)
}