From b528efd34e509ef017ddedb47be85292d54ac024 Mon Sep 17 00:00:00 2001 From: "Kimi.Wang" Date: Thu, 3 Aug 2023 10:37:53 +0800 Subject: [PATCH] only execute stream callback when non-nil (#121) Currently, if `nil` is returned as a stream callback, it will cause a panic because we try to call a `nil` func. This makes it valid to return a `nil` callback from the stream job, which just does nothing on callback. --- stream/stream.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stream/stream.go b/stream/stream.go index d80a923..6b11e90 100644 --- a/stream/stream.go +++ b/stream/stream.go @@ -128,7 +128,9 @@ func (s *Stream) callbacker() { callback := <-callbackCh // Execute the callback (with panic protection). - panicCatcher.Try(callback) + if callback != nil { + panicCatcher.Try(callback) + } // Return the channel to the pool of unused channels. putCh(callbackCh)