Skip to content

Commit

Permalink
Fix marshalling of raw_message field for empty messages (#106)
Browse files Browse the repository at this point in the history
* Fix marshalling of raw_message field for empty messages

* Add changelog entry

* Fix null vs "" marshalling
  • Loading branch information
bradleyjkemp authored Jun 30, 2020
1 parent e8dcb5d commit 33bc0ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Unreleased
* Fixed a bug that prevented replaying empty gRPC messages [#105](https://github.com/bradleyjkemp/grpc-tools/pull/105).

## [v0.2.5](https://github.com/bradleyjkemp/grpc-tools/releases/tag/v0.2.5)
* Added grpc-proxy options `WithServerOptions` and `WithDialOptions`, deprecated `WithOptions` [#71](https://github.com/bradleyjkemp/grpc-tools/pull/71).
* Added a new command-line option, `--interface` to allow choosing which network interface `grpc-proxy` listens on [#81](https://github.com/bradleyjkemp/grpc-tools/pull/81).
Expand Down
4 changes: 4 additions & 0 deletions grpc-dump/dump/recorded_server_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (ss *recordedServerStream) SetTrailer(trailers metadata.MD) {

func (ss *recordedServerStream) SendMsg(m interface{}) error {
message := m.([]byte)
if message == nil {
// although the message is nil here, we actually want to save it as the empty message ("")
message = []byte{}
}
ss.Lock()
ss.events = append(ss.events, &internal.Message{
MessageOrigin: internal.ServerMessage,
Expand Down
2 changes: 1 addition & 1 deletion internal/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (

type Message struct {
MessageOrigin MessageOrigin `json:"message_origin,omitempty"`
RawMessage []byte `json:"raw_message,omitempty"`
RawMessage []byte `json:"raw_message"`
Message interface{} `json:"message,omitempty"`
Timestamp time.Time `json:"timestamp"`
}

0 comments on commit 33bc0ca

Please sign in to comment.