From a817315bb87572a993a9ace3279f53282b546046 Mon Sep 17 00:00:00 2001 From: Tzahi Levi Date: Mon, 27 Nov 2023 14:10:41 +0200 Subject: [PATCH 1/3] set request config to httpClientBuilder --- .../src/main/java/org/geowebcache/util/HttpClientBuilder.java | 1 + 1 file changed, 1 insertion(+) 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 8045bda577..920d618ed2 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); } From 4adb06924fa89ca4d8a68b50f5c99a558cf34059 Mon Sep 17 00:00:00 2001 From: Tzahi Levi Date: Mon, 27 Nov 2023 14:44:53 +0200 Subject: [PATCH 2/3] consume http entity on error --- .../org/geowebcache/layer/wms/WMSHttpHelper.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 58fa3b66c4..9798393b94 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,21 @@ 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"); + } + // try (InputStream stream = method.getEntity().getContent()) { + // byte[] error = IOUtils.toByteArray(stream); + // String message = new String(error); + // System.out.println( + // "error with the backend: " + message + " try to release + // content"); + // // release the connection to the poll + // } catch (IOException ioe) { + // } throw new ServiceException( "Unexpected response code from backend: " + responseCode From 13a5175bfb6309d46c96119ff040ecddff899a43 Mon Sep 17 00:00:00 2001 From: Tzahi Levi Date: Mon, 27 Nov 2023 14:46:40 +0200 Subject: [PATCH 3/3] remove comment --- .../java/org/geowebcache/layer/wms/WMSHttpHelper.java | 9 --------- 1 file changed, 9 deletions(-) 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 9798393b94..efe90b1ee8 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 @@ -206,15 +206,6 @@ private void connectAndCheckHeaders( } catch (IOException ex) { log.log(Level.WARNING, "failed to release connection"); } - // try (InputStream stream = method.getEntity().getContent()) { - // byte[] error = IOUtils.toByteArray(stream); - // String message = new String(error); - // System.out.println( - // "error with the backend: " + message + " try to release - // content"); - // // release the connection to the poll - // } catch (IOException ioe) { - // } throw new ServiceException( "Unexpected response code from backend: " + responseCode