Skip to content

Commit

Permalink
Polish "Support JDK HttpClient in ClientHttpRequestFactories"
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jul 6, 2023
1 parent 3bbfee5 commit bb2c4cc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ public final class ClientHttpRequestFactories {

private static final boolean JETTY_CLIENT_PRESENT = ClassUtils.isPresent(JETTY_CLIENT_CLASS, null);

static final String JDK_CLIENT_CLASS = "java.net.http.HttpClient";

private static final boolean JDK_CLIENT_PRESENT = ClassUtils.isPresent(JDK_CLIENT_CLASS, null);

private ClientHttpRequestFactories() {
}

Expand All @@ -104,9 +100,6 @@ public static ClientHttpRequestFactory get(ClientHttpRequestFactorySettings sett
if (JETTY_CLIENT_PRESENT) {
return Jetty.get(settings);
}
if (JDK_CLIENT_PRESENT) {
return Jdk.get(settings);
}
return Simple.get(settings);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* @author Andy Wilkinson
*/
@ClassPathExclusions(files = {"httpclient5-*.jar", "jetty-client-*.jar", "okhttp-*.jar"}, packages = "java.net.http")
@ClassPathExclusions({ "httpclient5-*.jar", "jetty-client-*.jar", "okhttp-*.jar" })
class ClientHttpRequestFactoriesSimpleTests
extends AbstractClientHttpRequestFactoriesTests<SimpleClientHttpRequestFactory> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;

Expand Down Expand Up @@ -75,6 +76,13 @@ void getOfOkHttpFactoryReturnsOkHttpFactory() {
assertThat(requestFactory).isInstanceOf(OkHttp3ClientHttpRequestFactory.class);
}

@Test
void getOfJdkFactoryReturnsJdkFactory() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(JdkClientHttpRequestFactory.class,

This comment has been minimized.

Copy link
@spencergibb

spencergibb Jul 6, 2023

Member

Feels like this should be documented as the way to activate this new feature.

This comment has been minimized.

Copy link
@wilkinsona

wilkinsona Jul 6, 2023

Author Member

See #36267 and its forward ports.

This comment has been minimized.

Copy link
@spencergibb

spencergibb Jul 6, 2023

Member

Thanks

ClientHttpRequestFactorySettings.DEFAULTS);
assertThat(requestFactory).isInstanceOf(JdkClientHttpRequestFactory.class);
}

@Test
void getOfUnknownTypeCreatesFactory() {
ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(TestClientHttpRequestFactory.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @author Stephane Nicoll
*/
@ClassPathExclusions(files = { "httpclient5-*.jar", "jetty-client-*.jar", "okhttp*.jar" }, packages = "java.net.http")
@ClassPathExclusions({ "httpclient5-*.jar", "jetty-client-*.jar", "okhttp*.jar" })
class HttpWebServiceMessageSenderBuilderSimpleIntegrationTests {

private final HttpWebServiceMessageSenderBuilder builder = new HttpWebServiceMessageSenderBuilder();
Expand Down

0 comments on commit bb2c4cc

Please sign in to comment.