added temporary debug output in http client

pull/8/head
Michael Peter Christen 10 years ago
parent ff29b0e503
commit fbf85a1561

@ -166,7 +166,7 @@ public class HTTPClient {
builder.setUserAgent(ClientIdentification.yacyInternetCrawlerAgent.userAgent); builder.setUserAgent(ClientIdentification.yacyInternetCrawlerAgent.userAgent);
// remove retries; we expect connections to fail; therefore we should not retry // remove retries; we expect connections to fail; therefore we should not retry
builder.disableAutomaticRetries(); //builder.disableAutomaticRetries();
// disable the cookiestore, cause this may cause segfaults and is not needed // disable the cookiestore, cause this may cause segfaults and is not needed
builder.setDefaultCookieStore(null); builder.setDefaultCookieStore(null);
builder.disableCookieManagement(); builder.disableCookieManagement();
@ -677,11 +677,12 @@ public class HTTPClient {
Thread.currentThread().setName("HTTPClient-" + httpUriRequest.getURI()); Thread.currentThread().setName("HTTPClient-" + httpUriRequest.getURI());
final long time = System.currentTimeMillis(); final long time = System.currentTimeMillis();
try { try {
final CloseableHttpClient client = clientBuilder.build();
if (concurrent) { if (concurrent) {
FutureTask<CloseableHttpResponse> t = new FutureTask<CloseableHttpResponse>(new Callable<CloseableHttpResponse>() { FutureTask<CloseableHttpResponse> t = new FutureTask<CloseableHttpResponse>(new Callable<CloseableHttpResponse>() {
@Override @Override
public CloseableHttpResponse call() throws ClientProtocolException, IOException { public CloseableHttpResponse call() throws ClientProtocolException, IOException {
final CloseableHttpClient client = clientBuilder.build();
CloseableHttpResponse response = client.execute(httpUriRequest, context); CloseableHttpResponse response = client.execute(httpUriRequest, context);
return response; return response;
} }
@ -693,8 +694,9 @@ public class HTTPClient {
throw e.getCause(); throw e.getCause();
} catch (Throwable e) {} } catch (Throwable e) {}
try {t.cancel(true);} catch (Throwable e) {} try {t.cancel(true);} catch (Throwable e) {}
if (this.httpResponse == null) throw new IOException("timout to client after " + this.timeout + "ms"); if (this.httpResponse == null) throw new IOException("timout to client after " + this.timeout + "ms" + " for url " + httpUriRequest.getURI().toString());
} else { } else {
final CloseableHttpClient client = clientBuilder.build();
this.httpResponse = client.execute(httpUriRequest, context); this.httpResponse = client.execute(httpUriRequest, context);
} }
this.httpResponse.setHeader(HeaderFramework.RESPONSE_TIME_MILLIS, Long.toString(System.currentTimeMillis() - time)); this.httpResponse.setHeader(HeaderFramework.RESPONSE_TIME_MILLIS, Long.toString(System.currentTimeMillis() - time));
@ -702,9 +704,10 @@ public class HTTPClient {
ConnectionInfo.removeConnection(httpUriRequest.hashCode()); ConnectionInfo.removeConnection(httpUriRequest.hashCode());
httpUriRequest.abort(); httpUriRequest.abort();
if (this.httpResponse != null) this.httpResponse.close(); if (this.httpResponse != null) this.httpResponse.close();
e.printStackTrace();
throw new IOException("Client can't execute: " throw new IOException("Client can't execute: "
+ (e.getCause() == null ? e.getMessage() : e.getCause().getMessage()) + (e.getCause() == null ? e.getMessage() : e.getCause().getMessage())
+ " duration=" + Long.toString(System.currentTimeMillis() - time)); + " duration=" + Long.toString(System.currentTimeMillis() - time) + " for url " + httpUriRequest.getURI().toString());
} }
} }

Loading…
Cancel
Save