Skip to content

Commit

Permalink
Merge "[FAB-5339] Add missing nil check to extensions.go"
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersingh24 authored and Gerrit Code Review committed Jul 18, 2017
2 parents 2967a0b + 3cde835 commit 97d4846
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion protos/gossip/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (m *SignedGossipMessage) String() string {
var isSimpleMsg bool
if m.GetStateResponse() != nil {
gMsg = fmt.Sprintf("StateResponse with %d items", len(m.GetStateResponse().Payloads))
} else if m.IsDataMsg() {
} else if m.IsDataMsg() && m.GetDataMsg().Payload != nil {
gMsg = m.GetDataMsg().Payload.toString()
} else if m.IsDataUpdate() {
update := m.GetDataUpdate()
Expand Down
4 changes: 4 additions & 0 deletions protos/gossip/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func TestToString(t *testing.T) {
},
}
assert.NotContains(t, fmt.Sprintf("%v", sMsg), "2")
sMsg.GetDataMsg().Payload = nil
assert.NotPanics(t, func() {
_ = sMsg.String()
})

sMsg = &SignedGossipMessage{
GossipMessage: &GossipMessage{
Expand Down

0 comments on commit 97d4846

Please sign in to comment.