Skip to content

Commit

Permalink
fix connectionMonitor in RestProtocol seems not work apache#3237
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyHZM committed Feb 12, 2019
1 parent fa2316e commit 09bf183
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class RestProtocol extends AbstractProxyProtocol {

private static final int HTTPCLIENTCONNECTIONMANAGER_MAXPERROUTE = 20;
private static final int HTTPCLIENTCONNECTIONMANAGER_MAXTOTAL = 20;
private static final int HTTPCLIENT_KEEPALIVEDURATION = 30*1000;
private static final int HTTPCLIENT_KEEPALIVEDURATION = 30 * 1000;
private static final int HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS = 1000;
private static final int HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S = 30;

Expand All @@ -70,7 +70,7 @@ public class RestProtocol extends AbstractProxyProtocol {
private final RestServerFactory serverFactory = new RestServerFactory();

// TODO in the future maybe we can just use a single rest client and connection manager
private final List<ResteasyClient> clients = Collections.synchronizedList(new LinkedList<ResteasyClient>());
private final List<ResteasyClient> clients = Collections.synchronizedList(new LinkedList<>());

private volatile ConnectionMonitor connectionMonitor;

Expand Down Expand Up @@ -147,6 +147,7 @@ protected <T> T doRefer(Class<T> serviceType, URL url) throws RpcException {
connectionManager.setDefaultMaxPerRoute(url.getParameter(Constants.CONNECTIONS_KEY, HTTPCLIENTCONNECTIONMANAGER_MAXPERROUTE));

connectionMonitor.addConnectionManager(connectionManager);
connectionMonitor.run();
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT))
.setSocketTimeout(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT))
Expand Down Expand Up @@ -239,7 +240,7 @@ public void destroy() {

protected String getContextPath(URL url) {
String contextPath = url.getPath();
return contextPath.endsWith("/") ? contextPath.substring(0,contextPath.length()-1) : contextPath;
return contextPath.endsWith("/") ? contextPath.substring(0, contextPath.length() - 1) : contextPath;
}

protected class ConnectionMonitor extends Thread {
Expand Down

0 comments on commit 09bf183

Please sign in to comment.