Skip to content

Commit

Permalink
Improve Jetty 10 check on client-side
Browse files Browse the repository at this point in the history
Before this commit, JettyClientHttpResponse checked for the presence of
a server-side class to determine whether it is running on Jetty 10.
Unfortunately, that class is not necessarily present when just using the
Jetty client.

This commit improves the Jetty 10 check, so that it also works when
the Jetty client is used without the server.

Closes gh-27136
  • Loading branch information
poutsma committed Jul 6, 2021
1 parent cb25134 commit 94f56a2
Showing 1 changed file with 12 additions and 3 deletions.
Expand Up @@ -33,7 +33,6 @@
import org.springframework.http.ResponseCookie;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
Expand All @@ -53,8 +52,7 @@ class JettyClientHttpResponse implements ClientHttpResponse {

private static final ClassLoader loader = JettyClientHttpResponse.class.getClassLoader();

private static final boolean jetty10Present = ClassUtils.isPresent(
"org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer", loader);
private static final boolean jetty10Present;


private final ReactiveResponse reactiveResponse;
Expand All @@ -64,6 +62,17 @@ class JettyClientHttpResponse implements ClientHttpResponse {
private final HttpHeaders headers;


static {
try {
Class<?> httpFieldsClass = loader.loadClass("org.eclipse.jetty.http.HttpFields");
jetty10Present = httpFieldsClass.isInterface();
}
catch (ClassNotFoundException ex) {
throw new IllegalStateException("No compatible Jetty version found", ex);
}
}


public JettyClientHttpResponse(ReactiveResponse reactiveResponse, Publisher<DataBuffer> content) {
this.reactiveResponse = reactiveResponse;
this.content = Flux.from(content);
Expand Down

0 comments on commit 94f56a2

Please sign in to comment.