Commit 0e10b2a8 authored by Rohit Jnagal's avatar Rohit Jnagal

Merge pull request #6434 from alml/silent-watcher-close

Ignore errors after StreamWatcher is closed
parents dbbfac3b 952ff24f
......@@ -76,6 +76,13 @@ func (sw *StreamWatcher) Stop() {
}
}
// stopping returns true if Stop() was called previously.
func (sw *StreamWatcher) stopping() bool {
sw.Lock()
defer sw.Unlock()
return sw.stopped
}
// receive reads result from the decoder in a loop and sends down the result channel.
func (sw *StreamWatcher) receive() {
defer close(sw.result)
......@@ -84,6 +91,10 @@ func (sw *StreamWatcher) receive() {
for {
action, obj, err := sw.source.Decode()
if err != nil {
// Ignore expected error.
if sw.stopping() {
return
}
switch err {
case io.EOF:
// watch closed normally
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment