diff --git a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java index 58fa3b66c..efe90b1ee 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java +++ b/geowebcache/core/src/main/java/org/geowebcache/layer/wms/WMSHttpHelper.java @@ -36,6 +36,7 @@ import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.entity.StringEntity; import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; import org.geotools.util.logging.Logging; import org.geowebcache.GeoWebCacheException; import org.geowebcache.io.Resource; @@ -199,6 +200,12 @@ private void connectAndCheckHeaders( tileRespRecv.setStatus(responseCode); if (responseCode != 200 && responseCode != 204) { tileRespRecv.setError(); + try { + log.fine("Try release connection through an error"); + EntityUtils.consume(method.getEntity()); + } catch (IOException ex) { + log.log(Level.WARNING, "failed to release connection"); + } throw new ServiceException( "Unexpected response code from backend: " + responseCode diff --git a/geowebcache/core/src/main/java/org/geowebcache/util/HttpClientBuilder.java b/geowebcache/core/src/main/java/org/geowebcache/util/HttpClientBuilder.java index 8045bda57..920d618ed 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/util/HttpClientBuilder.java +++ b/geowebcache/core/src/main/java/org/geowebcache/util/HttpClientBuilder.java @@ -81,6 +81,7 @@ public HttpClientBuilder( clientBuilder = org.apache.http.impl.client.HttpClientBuilder.create(); clientBuilder.useSystemProperties(); clientBuilder.setConnectionManager(connectionManager); + clientBuilder.setDefaultRequestConfig(getConnectionConfig()); clientBuilder.setMaxConnTotal(concurrency); }