diff --git a/decode_stream.go b/decode_stream.go index bd38d79..43a1d37 100644 --- a/decode_stream.go +++ b/decode_stream.go @@ -60,9 +60,9 @@ func (d *JSONStreamCommandDecoder) Decode() (*Command, int, error) { if err != nil { if err == io.EOF && len(cmdBytes) > 0 { var c Command - _, err = json.Parse(cmdBytes, &c, 0) - if err != nil { - return nil, 0, err + _, parseErr := json.Parse(cmdBytes, &c, 0) + if parseErr != nil { + return nil, 0, parseErr } return &c, len(cmdBytes), err } diff --git a/decode_stream_test.go b/decode_stream_test.go index 4bc35d9..5e86606 100644 --- a/decode_stream_test.go +++ b/decode_stream_test.go @@ -89,13 +89,17 @@ func testDecodingFrame(tb testing.TB, frame []byte, protoType Type) { require.Equal(tb, 10037, size) } _, size, err = dec.Decode() - require.NoError(tb, err) if protoType == TypeProtobuf { require.Equal(tb, 10018, size) } else { require.Equal(tb, 10036, size) } - _, _, err = dec.Decode() - require.ErrorIs(tb, err, io.EOF) + if err != nil { + require.ErrorIs(tb, err, io.EOF) + } else { + _, _, err = dec.Decode() + require.ErrorIs(tb, err, io.EOF) + } + PutStreamCommandDecoder(protoType, dec) }