Skip to content

Commit

Permalink
Merge pull request Netflix#204 from VijithaEkanayake/1.x
Browse files Browse the repository at this point in the history
Fixing issue of cleaning expired connections in Zuul-simple-webapp
  • Loading branch information
mikeycohen committed Mar 7, 2016
2 parents 53bdeb0 + 1a24fc6 commit 0b3ae9c
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,19 @@ class SimpleHostRoutingFilter extends ZuulFilter {
@Override
void run() {
try {
final CloseableHttpClient hc = CLIENT.get();

if (hc == null) {
return;
}

hc.close();
final HttpClient hc = CLIENT.get();
if (hc == null) return;
hc.getConnectionManager().closeExpiredConnections();
} catch (Throwable t) {
LOG.error("error closing expired connections", t);
}
}
}, 30000, 5000)
}

public SimpleHostRoutingFilter() {}
public SimpleHostRoutingFilter() {
super();
}

private static final HttpClientConnectionManager newConnectionManager() {
SSLContext sslContext = SSLContexts.createSystemDefault();
Expand Down Expand Up @@ -165,7 +163,7 @@ class SimpleHostRoutingFilter extends ZuulFilter {
HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
Header[] headers = buildZuulRequestHeaders(request)
String verb = getVerb(request);
InputStream requestEntity = getRequestBody(request)
InputStream requestEntity = request.getInputStream();
CloseableHttpClient httpclient = CLIENT.get()

String uri = request.getRequestURI()
Expand Down Expand Up @@ -226,7 +224,7 @@ class SimpleHostRoutingFilter extends ZuulFilter {
switch (verb) {
case 'POST':
httpRequest = new HttpPost(uri + getQueryString())
InputStreamEntity entity = new InputStreamEntity(requestEntity, request.getContentLength())
InputStreamEntity entity = new InputStreamEntity(requestEntity)
httpRequest.setEntity(entity)
break
case 'PUT':
Expand Down

0 comments on commit 0b3ae9c

Please sign in to comment.