Skip to content

Commit

Permalink
Fix NPE in streamutil.Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMertz committed May 22, 2018
1 parent 79ecd70 commit 391997a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions streamutil/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ func Errors(errs ...stream.ErrorCloser) <-chan error {
errChan := make(chan error)

for _, e := range errs {
if e == nil {
continue
}

go func(c <-chan error) {
for {
errChan <- (<-c)
Expand Down
4 changes: 3 additions & 1 deletion streamutil/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

"github.com/blendle/go-streamprocessor/stream"
"github.com/blendle/go-streamprocessor/streamutil"
"github.com/blendle/go-streamprocessor/streamutil/testutil"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -123,8 +124,9 @@ func TestErrors(t *testing.T) {

ec1 := &errorCloserStub{errors: make(chan error)}
ec2 := &errorCloserStub{errors: make(chan error)}
var ec3 stream.ErrorCloser

ch := streamutil.Errors(ec1, ec2)
ch := streamutil.Errors(ec1, ec2, ec3)

go func() { ec1.errors <- errors.New("error 1") }()

Expand Down

0 comments on commit 391997a

Please sign in to comment.