Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

stupid me: revert placement of closing connection which caused unclosed connections + reuse sockets

sixcooler65bcc608086a
diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.java
index cf4f451b6..ac476998e 100644
--- a/source/net/yacy/cora/protocol/http/HTTPClient.java
+++ b/source/net/yacy/cora/protocol/http/HTTPClient.java
@@ -147,7 +147,6 @@ public class HTTPClient {
HttpConnectionParams.setConnectionTimeout(httpParams, 9500);
// SO_LINGER affects the socket close operation in seconds
// HttpConnectionParams.setLinger(httpParams, 6);
- // TODO: is default ok?
// HttpConnectionParams.setSocketBufferSize(httpParams, 8192);
// SO_TIMEOUT: maximum period inactivity between two consecutive data packets in milliseconds
HttpConnectionParams.setSoTimeout(httpParams, 9900);
@@ -155,7 +154,8 @@ public class HTTPClient {
HttpConnectionParams.setStaleCheckingEnabled(httpParams, true);
// conserve bandwidth by minimizing the number of segments that are sent
HttpConnectionParams.setTcpNoDelay(httpParams, false);
- // TODO: testing noreuse - there will be HttpConnectionParams.setSoReuseaddr(HttpParams params, boolean reuseaddr) in core-4.1
+ // TODO: testing reuse of socket - there will be HttpConnectionParams.setSoReuseaddr(HttpParams params, boolean reuseaddr) in core-4.1
+ HttpConnectionParams.setSoReuseaddr(httpParams, true);
httpClient = new DefaultHttpClient(clientConnectionManager, httpParams);
// ask for gzip
@@ -453,11 +453,10 @@ public class HTTPClient {
content = EntityUtils.toByteArray(httpEntity);
} catch (OutOfMemoryError e) {
throw new IOException(e.toString());
- } finally {
- // Ensures that the entity content is fully consumed and the content stream, if exists, is closed.
- EntityUtils.consume(httpEntity);
}
- }
+ }
+ // Ensures that the entity content is fully consumed and the content stream, if exists, is closed.
+ EntityUtils.consume(httpEntity);
}
} catch (final IOException e) {
ConnectionInfo.removeConnection(httpUriRequest.hashCode());