apache / apache/dubbo-go-hessian2

nil encoding not correct

Open
#369 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
228
Forks
123
PR merge metrics
No merged PRs in 30d

Description

**What happened**:
In the previous implementation, dubbo-go-hessian2 would encode nil values of a specified type as empty bytes.

For example:
```go
var null *int = nil

e := NewEncoder()
e.Encode(null)

len(e.buffer) == 0 // true
```

However, the expected encoding for nil values should be []byte("N"), regardless of the type of nil value.

**What you expected to happen**:
It encodes nil values of any type as []byte("N").

**How to reproduce it (as minimally and precisely as possible)**:

**Anything else we need to know?**:

Contributor guide

Open the contributing guide

Research direction

Start at the NewEncoder and Encode entry points and reproduce the nil pointer example from the issue. Trace how nil values are written and verify the encoder output for nil values of different specified types. Done means every nil value encodes as the single byte "N" rather than an empty buffer.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.