Skip to content

Commit 1881e48

Browse files
committed
Remove Jetty dependencies from JdkHttpClientResourceFactory
This commit removes the Eclipse Jetty dependencies from JdkHttpClientResourceFactory, replacing them with a check for ExecutorService. Closes gh-28588
1 parent 7e8b1ed commit 1881e48

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

spring-web/src/main/java/org/springframework/http/client/reactive/JdkHttpClientResourceFactory.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,12 +18,10 @@
1818

1919
import java.net.http.HttpClient;
2020
import java.util.concurrent.Executor;
21+
import java.util.concurrent.ExecutorService;
2122
import java.util.concurrent.Executors;
2223
import java.util.concurrent.ThreadFactory;
2324

24-
import org.eclipse.jetty.util.component.LifeCycle;
25-
import org.eclipse.jetty.util.thread.QueuedThreadPool;
26-
2725
import org.springframework.beans.factory.DisposableBean;
2826
import org.springframework.beans.factory.InitializingBean;
2927
import org.springframework.lang.Nullable;
@@ -70,10 +68,10 @@ public Executor getExecutor() {
7068
}
7169

7270
/**
73-
* Configure the thread prefix to initialize {@link QueuedThreadPool} executor with. This
71+
* Configure the thread prefix to initialize the executor with. This
7472
* is used only when a {@link Executor} instance isn't
7573
* {@link #setExecutor(Executor) provided}.
76-
* <p>By default set to "jetty-http".
74+
* <p>By default set to "jdk-http".
7775
* @param threadPrefix the thread prefix to use
7876
*/
7977
public void setThreadPrefix(String threadPrefix) {
@@ -88,20 +86,12 @@ public void afterPropertiesSet() throws Exception {
8886
String name = this.threadPrefix + "@" + Integer.toHexString(hashCode());
8987
this.executor = Executors.newCachedThreadPool(new CustomizableThreadFactory(name));
9088
}
91-
if (this.executor instanceof LifeCycle) {
92-
((LifeCycle)this.executor).start();
93-
}
9489
}
9590

9691
@Override
9792
public void destroy() throws Exception {
98-
try {
99-
if (this.executor instanceof LifeCycle) {
100-
((LifeCycle)this.executor).stop();
101-
}
102-
}
103-
catch (Throwable ex) {
104-
// ignore
93+
if (this.executor instanceof ExecutorService executorService) {
94+
executorService.shutdown();
10595
}
10696
}
10797

0 commit comments

Comments
 (0)