diff --git a/src/encoding/json/jsontext/decode.go b/src/encoding/json/jsontext/decode.go
index 0e1ff4b..e04ecfc 100644
--- a/src/encoding/json/jsontext/decode.go
+++ b/src/encoding/json/jsontext/decode.go
@@ -133,8 +133,6 @@
switch {
case d == nil:
panic("jsontext: invalid nil Decoder")
- case r == nil:
- panic("jsontext: invalid nil io.Reader")
case d.s.Flags.Get(jsonflags.WithinArshalCall):
panic("jsontext: cannot reset Decoder passed to json.UnmarshalerFrom")
}
diff --git a/src/encoding/json/jsontext/decode_test.go b/src/encoding/json/jsontext/decode_test.go
index 3f48cae..93a6023 100644
--- a/src/encoding/json/jsontext/decode_test.go
+++ b/src/encoding/json/jsontext/decode_test.go
@@ -1347,4 +1347,13 @@
t.Fatalf("decoder buffer aliases bytes.Buffer")
}
})
+
+ t.Run("Test ability to reset nil reader", func(t *testing.T) {
+ defer func() {
+ if recover() != nil {
+ t.Fatalf("decoder.Reset(nil) shouldn`t panic")
+ }
+ }()
+ dec.Reset(nil)
+ })
}
diff --git a/src/encoding/json/jsontext/encode.go b/src/encoding/json/jsontext/encode.go
index 116e150..c5fedbe 100644
--- a/src/encoding/json/jsontext/encode.go
+++ b/src/encoding/json/jsontext/encode.go
@@ -102,8 +102,6 @@
switch {
case e == nil:
panic("jsontext: invalid nil Encoder")
- case w == nil:
- panic("jsontext: invalid nil io.Writer")
case e.s.Flags.Get(jsonflags.WithinArshalCall):
panic("jsontext: cannot reset Encoder passed to json.MarshalerTo")
}
diff --git a/src/encoding/json/jsontext/encode_test.go b/src/encoding/json/jsontext/encode_test.go
index c5dcbdf..fa1046c 100644
--- a/src/encoding/json/jsontext/encode_test.go
+++ b/src/encoding/json/jsontext/encode_test.go
@@ -826,4 +826,13 @@
t.Fatalf("encoder buffer aliases bytes.Buffer")
}
})
+
+ t.Run("Test ability to reset nil writer", func(t *testing.T) {
+ defer func() {
+ if recover() != nil {
+ t.Fatalf("encoder.Reset(nil) shouldn`t panic")
+ }
+ }()
+ enc.Reset(nil)
+ })
}