Skip to content

Commit 073ce43

Browse files
committed
FAB-302: fix panic for block-listener
when receive a rejection event with no "-listen-to-rejections", adapter of block-listener push a nil to notfy channel. This will cause nil pointer panic. Fix the handle logic. Change-Id: I8391af03acf32c6d99d613db6e2e7dc13d2424cc Signed-off-by: jiangyaoguo <[email protected]>
1 parent 165c0ed commit 073ce43

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/events/block-listener/block-listener.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ func (a *adapter) Recv(msg *pb.Event) (bool, error) {
5757
a.notfy <- o
5858
return true, nil
5959
}
60-
if o, e := msg.Event.(*pb.Event_Rejection); e && a.listenToRejections {
61-
a.rejected <- o
60+
if o, e := msg.Event.(*pb.Event_Rejection); e {
61+
if a.listenToRejections {
62+
a.rejected <- o
63+
}
6264
return true, nil
6365
}
6466
if o, e := msg.Event.(*pb.Event_ChaincodeEvent); e {
6567
a.cEvent <- o
6668
return true, nil
6769
}
68-
a.notfy <- nil
69-
return false, nil
70+
return false, fmt.Errorf("Receive unkown type event: %v", msg)
7071
}
7172

7273
//Disconnected implements consumer.EventAdapter interface for disconnecting

0 commit comments

Comments
 (0)