SOLR-8048: Close the http client in a finally clause at the end of the test

This commit is contained in:
Shalin Shekhar Mangar 2016-07-05 12:48:04 +05:30
parent 32e0f5fd25
commit 2d6b7ea966
1 changed files with 124 additions and 118 deletions

View File

@ -85,7 +85,9 @@ public class BasicAuthIntegrationTest extends TestMiniSolrCloudClusterBase {
cloudSolrClient.setDefaultCollection(null);
NamedList<Object> rsp;
HttpClient cl = HttpClientUtil.createClient(null);
HttpClient cl = null;
try {
cl = HttpClientUtil.createClient(null);
String baseUrl = getRandomReplica(zkStateReader.getClusterState().getCollection(defaultCollName), random()).getStr(BASE_URL_PROP);
verifySecurityStatus(cl, baseUrl + authcPrefix, "/errorMessages", null, 20);
zkClient.setData("/security.json", STD_CONF.replaceAll("'", "\"").getBytes(UTF_8), true);
@ -213,8 +215,12 @@ public class BasicAuthIntegrationTest extends TestMiniSolrCloudClusterBase {
"; stdout from tool prior to failure: " + baos.toString(StandardCharsets.UTF_8.name()));
}
executeCommand(baseUrl + authzPrefix, cl, "{set-property : { blockUnknown: false}}", "harry", "HarryIsUberCool");
} finally {
if (cl != null) {
HttpClientUtil.close(cl);
}
}
}
public static void executeCommand(String url, HttpClient cl, String payload, String user, String pwd) throws IOException {
HttpPost httpPost;