Skip to content

Commit

Permalink
Switch back to encoding/json from goccy/go-json
Browse files Browse the repository at this point in the history
Despite go-json having less allocations, it seems it has quite few
unresolved issues which might be hitting us, causing panics.

Signed-off-by: Tomasz Pietrek <[email protected]>
  • Loading branch information
Jarema committed Dec 4, 2024
1 parent d7239ac commit b4a97c7
Show file tree
Hide file tree
Showing 64 changed files with 64 additions and 69 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.22
toolchain go1.22.8

require (
github.com/goccy/go-json v0.10.3
github.com/google/go-tpm v0.9.0
github.com/klauspost/compress v1.17.11
github.com/minio/highwayhash v1.0.3
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/google/go-tpm v0.9.0 h1:sQF6YqWMi+SCXpsmS3fd21oPy/vSddwZry4JnmltHVk=
github.com/google/go-tpm v0.9.0/go.mod h1:FkNVkc6C+IsvDI9Jw1OveJmxGZUUaKxtrpOS47QWKfU=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
Expand Down
2 changes: 1 addition & 1 deletion server/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package server

import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"strconv"
Expand All @@ -24,7 +25,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
Expand Down
2 changes: 1 addition & 1 deletion server/auth_callout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package server
import (
"bytes"
"crypto/x509"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
Expand All @@ -28,7 +29,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
Expand Down
2 changes: 1 addition & 1 deletion server/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package server

import (
"context"
"encoding/json"
"fmt"
"net"
"net/url"
Expand All @@ -24,7 +25,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
)
Expand Down
2 changes: 1 addition & 1 deletion server/certidp/certidp.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/json"
"fmt"
"net/url"
"strings"
"time"

"github.com/goccy/go-json"
"golang.org/x/crypto/ocsp"
)

Expand Down
2 changes: 1 addition & 1 deletion server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"io"
Expand All @@ -32,7 +33,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats-server/v2/internal/fastrand"
Expand Down
2 changes: 1 addition & 1 deletion server/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"bufio"
"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"math"
Expand All @@ -31,7 +32,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
Expand Down
2 changes: 1 addition & 1 deletion server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package server
import (
"bytes"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -28,7 +29,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats-server/v2/server/avl"
"github.com/nats-io/nuid"
"golang.org/x/time/rate"
Expand Down
2 changes: 1 addition & 1 deletion server/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"compress/gzip"
"crypto/sha256"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -29,7 +30,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats-server/v2/server/certidp"
Expand Down
2 changes: 1 addition & 1 deletion server/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package server
import (
"bytes"
"crypto/sha256"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -29,7 +30,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
Expand Down
2 changes: 1 addition & 1 deletion server/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"hash"
Expand All @@ -39,7 +40,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/minio/highwayhash"
"github.com/nats-io/nats-server/v2/server/avl"
Expand Down
4 changes: 3 additions & 1 deletion server/filestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
Expand All @@ -39,7 +40,6 @@ import (
"time"
"unicode/utf8"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/nats-io/nuid"
)
Expand Down Expand Up @@ -1484,6 +1484,8 @@ func TestFileStoreMeta(t *testing.T) {
if err := json.Unmarshal(buf, &oconfig2); err != nil {
t.Fatalf("Error unmarshalling: %v", err)
}
// Since we set name we will get that back now.
oconfig.Name = oname
if !reflect.DeepEqual(oconfig2, oconfig) {
t.Fatalf("Consumer configs not equal, got %+v vs %+v", oconfig2, oconfig)
}
Expand Down
3 changes: 1 addition & 2 deletions server/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cmp"
"crypto/sha256"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -29,8 +30,6 @@ import (
"sync"
"sync/atomic"
"time"

"github.com/goccy/go-json"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion server/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"net"
"net/url"
Expand All @@ -30,7 +31,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats-server/v2/logger"
"github.com/nats-io/nats.go"
"golang.org/x/crypto/ocsp"
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"encoding/json"
"fmt"
"math"
"os"
Expand All @@ -29,7 +30,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/minio/highwayhash"
"github.com/nats-io/nats-server/v2/server/sysmem"
"github.com/nats-io/nats-server/v2/server/tpm"
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package server
import (
"bytes"
"cmp"
"encoding/json"
"errors"
"fmt"
"io"
Expand All @@ -30,7 +31,6 @@ import (
"time"
"unicode"

"github.com/goccy/go-json"
"github.com/nats-io/nuid"
)

Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cmp"
crand "crypto/rand"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math"
Expand All @@ -31,7 +32,6 @@ import (
"sync/atomic"
"time"

"github.com/goccy/go-json"
"github.com/klauspost/compress/s2"
"github.com/minio/highwayhash"
"github.com/nats-io/nuid"
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_cluster_1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"context"
crand "crypto/rand"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -32,7 +33,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
)
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_cluster_2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
crand "crypto/rand"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -36,7 +37,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats.go"
)

Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_cluster_3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package server
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -32,7 +33,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/jwt/v2"
"github.com/nats-io/nats.go"
)
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_cluster_4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package server
import (
"context"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -34,7 +35,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats.go"
"github.com/nats-io/nuid"
)
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package server

import (
"encoding/json"
"errors"
"fmt"
"math/rand"
Expand All @@ -28,7 +29,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats.go"
"github.com/nats-io/nuid"
)
Expand Down
3 changes: 1 addition & 2 deletions server/jetstream_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
package server

import (
"encoding/json"
"time"

"github.com/goccy/go-json"
)

func (s *Server) publishAdvisory(acc *Account, subject string, adv any) {
Expand Down
2 changes: 1 addition & 1 deletion server/jetstream_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package server

import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
Expand All @@ -32,7 +33,6 @@ import (
"testing"
"time"

"github.com/goccy/go-json"
"github.com/nats-io/nats.go"
"golang.org/x/time/rate"
)
Expand Down
Loading

0 comments on commit b4a97c7

Please sign in to comment.