Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Jetty HttpClient redirect issue going from M5 to RC0 (and above)

Hi,

I recently upgraded from jetty-client M5 to RC2 and have a problem with too many redirects after the upgrade. I tried this in RC0 and RC1 and had the same issue. Here's a simple test that demonstrates the problem …

SslContextFactory sslContextFactory = new SslContextFactory(true);
sslContextFactory.setEndpointIdentificationAlgorithm(null);
HttpClient client = new HttpClient(sslContextFactory);
// client.setMaxRedirects(Integer.MAX_VALUE);
client.start();
Request request = client.newRequest("http://www.twitter.com/jwallingford");
request.method(HttpMethod.GET);
try {
ContentResponse response = request.send();
System.out.println(response.getContentAsString());
} catch (InterruptedException | TimeoutException | ExecutionException e) {
e.printStackTrace();
} finally {
client.destroy();
}

When I run this in M5 it runs fine and prints the HTML for my Twitter page but in RC0-RC2 it returns the following exception …

java.util.concurrent.ExecutionException: org.eclipse.jetty.client.HttpResponseException: Max redirects exceeded 8
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:433)
at com.blogfrog.system.service.http.HttpClientServiceTest.main(HttpClientServiceTest.java:344)
Caused by: org.eclipse.jetty.client.HttpResponseException: Max redirects exceeded 8
at org.eclipse.jetty.client.RedirectProtocolHandler.redirect(RedirectProtocolHandler.java:140)
at org.eclipse.jetty.client.RedirectProtocolHandler.onComplete(RedirectProtocolHandler.java:76)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:199)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:191)
at org.eclipse.jetty.client.HttpReceiver.success(HttpReceiver.java:337)
at org.eclipse.jetty.client.HttpReceiver.messageComplete(HttpReceiver.java:305)
at org.eclipse.jetty.http.HttpParser.parseHeaders(HttpParser.java:775)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1087)
at org.eclipse.jetty.client.HttpReceiver.parse(HttpReceiver.java:111)
at org.eclipse.jetty.client.HttpReceiver.receive(HttpReceiver.java:78)
at org.eclipse.jetty.client.HttpConnection.receive(HttpConnection.java:308)
at org.eclipse.jetty.client.HttpExchange.receive(HttpExchange.java:104)
at org.eclipse.jetty.client.HttpConnection.onFillable(HttpConnection.java:296)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:278)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:78)
at org.eclipse.jetty.io.SelectChannelEndPoint.onSelected(SelectChannelEndPoint.java:109)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.processKey(SelectorManager.java:482)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:439)
at org.eclipse.jetty.io.SelectorManager$ManagedSelector.run(SelectorManager.java:404)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:589)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:520)
at java.lang.Thread.run(Thread.java:722)

The exception is pretty obvious so I tried setting the client's max redirects to Integer.MAX_VALUE but after that change it runs forever. I've tried a number of different URLs and get the same problem. I've also tried it with and without the SSLContextFactor and still get the same problem. I feel like I must be doing SOMETHING wrong here but the test is so simple I'm not sure what else to try.

Jay





Back to the top