Skip to content

Commit d72372e

Browse files
committed
Reduce visibility, remove propagateContextForTesting
1 parent 00e7609 commit d72372e

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

exporters/sender/jdk/src/main/java/io/opentelemetry/exporter/sender/jdk/internal/JdkHttpSender.java

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,6 @@ public final class JdkHttpSender implements HttpSender {
7575
@Nullable private final RetryPolicy retryPolicy;
7676
private final Predicate<IOException> retryExceptionPredicate;
7777

78-
/**
79-
* Returns an {@link ExecutorService} using daemon threads.
80-
*
81-
* @param propagateContextForTesting For tests only. When enabled, the current thread's Context
82-
* will be passed over to the new threads, this is useful for validating scenarios where
83-
* context propagation is available through bytecode instrumentation.
84-
*/
85-
public static ExecutorService newExecutor(boolean propagateContextForTesting) {
86-
return new ThreadPoolExecutor(
87-
0,
88-
Integer.MAX_VALUE,
89-
60,
90-
TimeUnit.SECONDS,
91-
new SynchronousQueue<>(),
92-
new DaemonThreadFactory("jdkhttp-executor", propagateContextForTesting));
93-
}
94-
9578
// Visible for testing
9679
JdkHttpSender(
9780
HttpClient client,
@@ -102,8 +85,7 @@ public static ExecutorService newExecutor(boolean propagateContextForTesting) {
10285
long timeoutNanos,
10386
Supplier<Map<String, List<String>>> headerSupplier,
10487
@Nullable RetryPolicy retryPolicy,
105-
@Nullable ExecutorService executorService,
106-
boolean propagateContextForTesting) {
88+
@Nullable ExecutorService executorService) {
10789
this.client = client;
10890
try {
10991
this.uri = new URI(endpoint);
@@ -121,7 +103,7 @@ public static ExecutorService newExecutor(boolean propagateContextForTesting) {
121103
.map(RetryPolicy::getRetryExceptionPredicate)
122104
.orElse(JdkHttpSender::isRetryableException);
123105
if (executorService == null) {
124-
this.executorService = JdkHttpSender.newExecutor(propagateContextForTesting);
106+
this.executorService = newExecutor();
125107
this.managedExecutor = true;
126108
} else {
127109
this.executorService = executorService;
@@ -150,8 +132,17 @@ public static ExecutorService newExecutor(boolean propagateContextForTesting) {
150132
timeoutNanos,
151133
headerSupplier,
152134
retryPolicy,
153-
executorService,
154-
/* propagateContextForTesting= */ false);
135+
executorService);
136+
}
137+
138+
private static ExecutorService newExecutor() {
139+
return new ThreadPoolExecutor(
140+
0,
141+
Integer.MAX_VALUE,
142+
60,
143+
TimeUnit.SECONDS,
144+
new SynchronousQueue<>(),
145+
new DaemonThreadFactory("jdkhttp-executor"));
155146
}
156147

157148
private static HttpClient configureClient(

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ void setup() throws IOException, InterruptedException {
6363
Duration.ofSeconds(10).toNanos(),
6464
Collections::emptyMap,
6565
RetryPolicy.builder().setMaxAttempts(2).setInitialBackoff(Duration.ofMillis(1)).build(),
66-
null,
67-
true);
66+
null);
6867
}
6968

7069
@Test
@@ -90,8 +89,7 @@ void sendInternal_RetryableConnectException() throws IOException, InterruptedExc
9089
Duration.ofSeconds(10).toNanos(),
9190
Collections::emptyMap,
9291
RetryPolicy.builder().setMaxAttempts(2).setInitialBackoff(Duration.ofMillis(1)).build(),
93-
null,
94-
true);
92+
null);
9593

9694
assertThatThrownBy(() -> sender.sendInternal(new NoOpMarshaler()))
9795
.satisfies(

0 commit comments

Comments
 (0)