Skip to content

Commit dac35ca

Browse files
committed
Fix observationShouldNotLeakToFutureCompletionThread jdk 17 compatibility
Signed-off-by: pema4 <[email protected]>
1 parent 7eb9f94 commit dac35ca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

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

182-
try (var sameThreadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>())) {
182+
ThreadPoolExecutor sameThreadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS,
183+
new LinkedBlockingQueue<>());
184+
try {
183185
CompletableFuture<String> asyncResult = service
184186
.parent(() -> service.asyncChild(fakeAsyncTask, sameThreadExecutor));
185187
CompletableFuture<Void> asyncAssertion = asyncResult.thenRunAsync(
@@ -188,6 +190,9 @@ void observationShouldNotLeakToFutureCompletionThread() {
188190

189191
assertThat(asyncAssertion).succeedsWithin(Duration.ofMillis(200));
190192
}
193+
finally {
194+
sameThreadExecutor.shutdown();
195+
}
191196
}
192197

193198
@Test

0 commit comments

Comments
 (0)