Closed
Description
Hi,
after resolving golang/protobuf/jsonpb
compatibility issue, we found another issue with json decoder
Details can be found at etcd-io/etcd#5969 (comment).
To summarize
dec.Decode(&protoReq)
returns io.EOF
in this code (full generated code can be found https://github.com/coreos/etcd/blob/master/etcdserver/etcdserverpb/rpc.pb.gw.go#L92-L93):
func request_Watch_Watch_0(ctx context.Context, marshaler runtime.Marshaler, client WatchClient, req *http.Request, pathParams map[string]string) (Watch_WatchClient, runtime.ServerMetadata, error) {
var metadata runtime.ServerMetadata
stream, err := client.Watch(ctx)
if err != nil {
grpclog.Printf("Failed to start streaming: %v", err)
return nil, metadata, err
}
dec := marshaler.NewDecoder(req.Body)
handleSend := func() error {
var protoReq WatchRequest
err = dec.Decode(&protoReq)
if err != nil {
grpclog.Printf("Failed to decode request: %v", err)
return err
}
if err = stream.Send(&protoReq); err != nil {
grpclog.Printf("Failed to send request: %v", err)
return err
}
return nil
}
But if we manually make it handle io.EOF
as below:
dec := marshaler.NewDecoder(req.Body)
handleSend := func() error {
var protoReq WatchRequest
err = dec.Decode(&protoReq)
- if err != nil {
+ if err != nil && err != io.EOF {
where req.Body
is {"create_request": {"key": "Zm9v"}}
, everything works as expected.
Is there any way to make this decoder handle io.EOF
?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels