Skip to content

Commit 74dc274

Browse files
Update test to propagate context in thread.
1 parent 97bb4ec commit 74dc274

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

exporters/sender/jdk/src/test/java/io/opentelemetry/exporter/sender/jdk/internal/JdkHttpSenderTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.concurrent.TimeUnit;
2828
import javax.net.ssl.SSLException;
2929
import org.assertj.core.api.InstanceOfAssertFactories;
30+
import org.junit.jupiter.api.AfterEach;
3031
import org.junit.jupiter.api.BeforeEach;
3132
import org.junit.jupiter.api.Test;
3233
import org.junit.jupiter.api.extension.ExtendWith;
@@ -46,6 +47,8 @@ class JdkHttpSenderTest {
4647

4748
@BeforeEach
4849
void setup() throws IOException, InterruptedException {
50+
JdkHtttpUtil.setPropagateContextForTestingInDispatcher(true);
51+
4952
// Can't directly spy on HttpClient for some reason, so create a real instance and a mock that
5053
// delegates to the real thing
5154
when(mockHttpClient.send(any(), any()))
@@ -66,6 +69,11 @@ void setup() throws IOException, InterruptedException {
6669
null);
6770
}
6871

72+
@AfterEach
73+
void tearDown() {
74+
JdkHtttpUtil.setPropagateContextForTestingInDispatcher(false);
75+
}
76+
6977
@Test
7078
void sendInternal_RetryableConnectTimeoutException() throws IOException, InterruptedException {
7179
assertThatThrownBy(() -> sender.sendInternal(new NoOpMarshaler()))

0 commit comments

Comments
 (0)