Closed XWTiger closed 2 years ago
i found the response should close too
@Override public InputStream getFile(URI path) throws IOException { CloseableHttpResponse response = null; try { HttpGet getMethod = new HttpGet(path); response = client.execute(getMethod, localContext); jenkinsVersion = ResponseUtils.getJenkinsVersion(response); httpResponseValidator.validateResponse(response); return new RequestReleasingInputStream(response.getEntity().getContent(), getMethod); } finally { response.close(); }
}
i think it is better add timeout configuration to jenkins client
public JenkinsHttpClient(URI uri, HttpClientBuilder builder) { this(uri, initTimeOut(builder)); }
protected static CloseableHttpClient initTimeOut(HttpClientBuilder builder) {
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(6000)
.setConnectTimeout(6000)
.setSocketTimeout(6000)
.build();
CloseableHttpClient httpClient = builder.setMaxConnTotal(50).setMaxConnPerRoute(1000).setDefaultRequestConfig(requestConfig).build();
return httpClient;
}
Version report
Jenkins and plugins versions report:
Reproduction steps
Results
Expected result: if found the code stream was not be closed
Actual result: i think it should be like this