SOLR-7468: Close the cloud client created for test in a finally block.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1681413 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anshum Gupta 2015-05-24 05:28:43 +00:00
parent c3b3de98bb
commit 5a96141d7f
1 changed files with 27 additions and 23 deletions

View File

@ -146,30 +146,34 @@ public class TestSolrCloudWithKerberos extends AbstractFullDistribZkTestBase {
@Test @Test
public void testKerberizedSolr() throws Exception { public void testKerberizedSolr() throws Exception {
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); CloudSolrClient testClient = null;
CloudSolrClient testClient = createCloudClient("testcollection"); try {
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
testClient = createCloudClient("testcollection");
CollectionAdminRequest.Create create = new CollectionAdminRequest.Create(); CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
create.setCollectionName("testcollection"); create.setCollectionName("testcollection");
create.setConfigName("conf1"); create.setConfigName("conf1");
create.setNumShards(1); create.setNumShards(1);
create.setReplicationFactor(1); create.setReplicationFactor(1);
create.process(testClient); create.process(testClient);
waitForCollection(testClient.getZkStateReader(), "testcollection", 1); waitForCollection(testClient.getZkStateReader(), "testcollection", 1);
CollectionAdminRequest.List list = new CollectionAdminRequest.List(); CollectionAdminRequest.List list = new CollectionAdminRequest.List();
CollectionAdminResponse response = list.process(testClient); CollectionAdminResponse response = list.process(testClient);
assertTrue("Expected to see testcollection but it doesn't exist", assertTrue("Expected to see testcollection but it doesn't exist",
((ArrayList) response.getResponse().get("collections")).contains("testcollection")); ((ArrayList) response.getResponse().get("collections")).contains("testcollection"));
testClient.setDefaultCollection("testcollection"); testClient.setDefaultCollection("testcollection");
indexDoc(testClient, params("commit", "true"), getDoc("id", 1)); indexDoc(testClient, params("commit", "true"), getDoc("id", 1));
//cloudClient.commit();
QueryResponse queryResponse = testClient.query(new SolrQuery("*:*")); QueryResponse queryResponse = testClient.query(new SolrQuery("*:*"));
assertEquals("Expected #docs and actual isn't the same", 1, queryResponse.getResults().size()); assertEquals("Expected #docs and actual isn't the same", 1, queryResponse.getResults().size());
testClient.close(); } finally {
if(testClient != null)
testClient.close();
}
} }
@Override @Override