Skip to content

Commit 81ab808

Browse files
committed
Fix observationShouldNotLeakToFutureCompletionThread again
Signed-off-by: pema4 <[email protected]>
1 parent dac35ca commit 81ab808

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

samples/micrometer-samples-spring-framework6/src/test/java/io/micrometer/samples/spring6/aop/ObservedAspectTests.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,14 @@ void observationShouldNotLeakToFutureCompletionThread() {
179179
ObservedService service = pf.getProxy();
180180
FakeAsyncTask fakeAsyncTask = new FakeAsyncTask("test-result");
181181

182-
ThreadPoolExecutor sameThreadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS,
183-
new LinkedBlockingQueue<>());
184-
try {
185-
CompletableFuture<String> asyncResult = service
186-
.parent(() -> service.asyncChild(fakeAsyncTask, sameThreadExecutor));
187-
CompletableFuture<Void> asyncAssertion = asyncResult.thenRunAsync(
188-
() -> assertThat(registry).doesNotHaveAnyRemainingCurrentObservation(), sameThreadExecutor);
189-
fakeAsyncTask.proceed();
190-
191-
assertThat(asyncAssertion).succeedsWithin(Duration.ofMillis(200));
192-
}
193-
finally {
194-
sameThreadExecutor.shutdown();
195-
}
182+
ExecutorService sameThreadExecutor = Executors.newSingleThreadExecutor();
183+
CompletableFuture<String> asyncResult = service
184+
.parent(() -> service.asyncChild(fakeAsyncTask, sameThreadExecutor));
185+
CompletableFuture<Void> asyncAssertion = asyncResult
186+
.thenRunAsync(() -> assertThat(registry).doesNotHaveAnyRemainingCurrentObservation(), sameThreadExecutor);
187+
fakeAsyncTask.proceed();
188+
189+
assertThat(asyncAssertion).succeedsWithin(Duration.ofMillis(200));
196190
}
197191

198192
@Test

0 commit comments

Comments
 (0)