diff --git a/CHANGELOG.md b/CHANGELOG.md index ab004c7bcfe..f6895ab2f28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/exporters/trace/jaeger/reconnecting_udp_client_test.go b/exporters/trace/jaeger/reconnecting_udp_client_test.go index 6f4712634ac..f21d4c13b0f 100644 --- a/exporters/trace/jaeger/reconnecting_udp_client_test.go +++ b/exporters/trace/jaeger/reconnecting_udp_client_test.go @@ -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 @@ -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++ {