You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by el...@apache.org on 2018/06/14 16:26:09 UTC

[trafficcontrol] 07/07: Removed static on AsyncHttpClient to allow prevent leak warnings in Tomcat

This is an automated email from the ASF dual-hosted git repository.

elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 03e3b521214b87c343c34de2dccb0be882b0a01a
Author: Dewayne Richardson <de...@apache.org>
AuthorDate: Tue Jun 5 08:46:15 2018 -0600

    Removed static on AsyncHttpClient to allow prevent leak warnings in Tomcat
---
 .../traffic_router/core/util/PeriodicResourceUpdater.java           | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/PeriodicResourceUpdater.java b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/PeriodicResourceUpdater.java
index 7165f9f..5415bfb 100644
--- a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/PeriodicResourceUpdater.java
+++ b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/PeriodicResourceUpdater.java
@@ -52,7 +52,7 @@ import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
 public class PeriodicResourceUpdater {
 	private static final Logger LOGGER = Logger.getLogger(PeriodicResourceUpdater.class);
 
-	private static AsyncHttpClient asyncHttpClient;
+	private AsyncHttpClient asyncHttpClient;
 	protected String databaseLocation;
 	protected final ResourceUrl urls;
 	protected ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
@@ -143,7 +143,9 @@ public class PeriodicResourceUpdater {
 				final Request request = getRequest(urls.nextUrl());
 				if (request != null) {
 					request.getHeaders().add("Accept-Encoding", GZIP_ENCODING_STRING);
-					asyncHttpClient.executeRequest(request, new UpdateHandler(request)); // AsyncHandlers are NOT thread safe; one instance per request
+					if ((asyncHttpClient!=null) && (!asyncHttpClient.isClosed())) {
+						asyncHttpClient.executeRequest(request, new UpdateHandler(request)); // AsyncHandlers are NOT thread safe; one instance per request
+					}
 					return true;
 				}
 			} else {

-- 
To stop receiving notification emails like this one, please contact
elsloo@apache.org.