Commit 7718c626 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/rpc/jsonrpc: set exactly one of result or error to non-null in response

Fixes #7442

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/72570044
parent a35b9e49
......@@ -205,7 +205,6 @@ func TestMalformedOutput(t *testing.T) {
}
func TestServerErrorHasNullResult(t *testing.T) {
t.Skip("Known failing test; Issue 7442")
var out bytes.Buffer
sc := NewServerCodec(struct {
io.Reader
......
......@@ -100,7 +100,6 @@ func (c *serverCodec) ReadRequestBody(x interface{}) error {
var null = json.RawMessage([]byte("null"))
func (c *serverCodec) WriteResponse(r *rpc.Response, x interface{}) error {
var resp serverResponse
c.mutex.Lock()
b, ok := c.pending[r.Seq]
if !ok {
......@@ -114,10 +113,9 @@ func (c *serverCodec) WriteResponse(r *rpc.Response, x interface{}) error {
// Invalid request so no id. Use JSON null.
b = &null
}
resp.Id = b
resp.Result = x
resp := serverResponse{Id: b}
if r.Error == "" {
resp.Error = nil
resp.Result = x
} else {
resp.Error = r.Error
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment