Skip to content

Commit

Permalink
Bugfix jaeger exporter test panic (#1973)
Browse files Browse the repository at this point in the history
* fix jaeger exporter test panic with close closed channel

* add change to CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
hanyuancheung and MrAlias authored Jun 8, 2021
1 parent 4bf6150 commit 2088601
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- BatchSpanProcessor now drops span batches that failed to be exported. (#1860)
- Use `http://localhost:14268/api/traces` as default Jaeger collector endpoint instead of `http://localhost:14250`. (#1898)
- Allow trailing and leading whitespace in the parsing of a `tracestate` header. (#1931)
- Add logic to determine if the channel is closed to fix Jaeger exporter test panic with close closed channel. (#1870, #1973)

### Security

Expand Down
13 changes: 12 additions & 1 deletion exporters/trace/jaeger/reconnecting_udp_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func assertConnWritable(t *testing.T, conn udpConn, serverConn net.PacketConn) {
func waitForCallWithTimeout(call *mock.Call) bool {
called := make(chan struct{})
call.Run(func(args mock.Arguments) {
close(called)
if !isChannelClosed(called) {
close(called)
}
})

var wasCalled bool
Expand All @@ -114,6 +116,15 @@ func waitForCallWithTimeout(call *mock.Call) bool {
return wasCalled
}

func isChannelClosed(ch <-chan struct{}) bool {
select {
case <-ch:
return true
default:
}
return false
}

func waitForConnCondition(conn *reconnectingUDPConn, condition func(conn *reconnectingUDPConn) bool) bool {
var conditionVal bool
for i := 0; i < 10; i++ {
Expand Down

0 comments on commit 2088601

Please sign in to comment.