You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2015/05/24 07:28:44 UTC

svn commit: r1681413 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberos.java

Author: anshum
Date: Sun May 24 05:28:43 2015
New Revision: 1681413

URL: http://svn.apache.org/r1681413
Log:
SOLR-7468: Close the cloud client created for test in a finally block.

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberos.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberos.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberos.java?rev=1681413&r1=1681412&r2=1681413&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberos.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/TestSolrCloudWithKerberos.java Sun May 24 05:28:43 2015
@@ -146,30 +146,34 @@ public class TestSolrCloudWithKerberos e
   
   @Test
   public void testKerberizedSolr() throws Exception {
-    HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
-    CloudSolrClient testClient = createCloudClient("testcollection");
-    
-    CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
-    create.setCollectionName("testcollection");
-    create.setConfigName("conf1");
-    create.setNumShards(1);
-    create.setReplicationFactor(1);
-    create.process(testClient);
-    
-    waitForCollection(testClient.getZkStateReader(), "testcollection", 1);
-    CollectionAdminRequest.List list = new CollectionAdminRequest.List();
-    
-    CollectionAdminResponse response = list.process(testClient);
-    assertTrue("Expected to see testcollection but it doesn't exist",
-        ((ArrayList) response.getResponse().get("collections")).contains("testcollection"));
-    
-    testClient.setDefaultCollection("testcollection");
-    indexDoc(testClient, params("commit", "true"), getDoc("id", 1));
-    //cloudClient.commit();
+    CloudSolrClient testClient = null;
+    try {
+      HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
+      testClient = createCloudClient("testcollection");
 
-    QueryResponse queryResponse = testClient.query(new SolrQuery("*:*"));
-    assertEquals("Expected #docs and actual isn't the same", 1, queryResponse.getResults().size());
-    testClient.close();
+      CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
+      create.setCollectionName("testcollection");
+      create.setConfigName("conf1");
+      create.setNumShards(1);
+      create.setReplicationFactor(1);
+      create.process(testClient);
+
+      waitForCollection(testClient.getZkStateReader(), "testcollection", 1);
+      CollectionAdminRequest.List list = new CollectionAdminRequest.List();
+
+      CollectionAdminResponse response = list.process(testClient);
+      assertTrue("Expected to see testcollection but it doesn't exist",
+          ((ArrayList) response.getResponse().get("collections")).contains("testcollection"));
+
+      testClient.setDefaultCollection("testcollection");
+      indexDoc(testClient, params("commit", "true"), getDoc("id", 1));
+
+      QueryResponse queryResponse = testClient.query(new SolrQuery("*:*"));
+      assertEquals("Expected #docs and actual isn't the same", 1, queryResponse.getResults().size());
+    } finally {
+      if(testClient != null)
+        testClient.close();
+    }
   }
   
   @Override