Project

General

Profile

« Previous | Next » 

Revision 49044

do not close the client too early

View differences:

CloudIndexClientFactory.java
14 14

  
15 15
	public static CloudIndexClient newIndexClient(final String baseURL, final String collection, final boolean parallelUpdates)
16 16
			throws CloudIndexClientException {
17
		try {
18
			final CloudSolrClient client = new CloudSolrClient.Builder().withZkHost(baseURL).build();
17 19

  
18
		try(final CloudSolrClient solrServer = new CloudSolrClient.Builder().withZkHost(baseURL).build()) {
19

  
20 20
			log.info(String.format("Initializing solr server (%s) ...", baseURL));
21 21

  
22
			solrServer.connect();
22
			client.connect();
23 23

  
24
			solrServer.setParallelUpdates(parallelUpdates);
25
			solrServer.setDefaultCollection(collection);
24
			client.setParallelUpdates(parallelUpdates);
25
			client.setDefaultCollection(collection);
26 26

  
27
			final SolrPingResponse rsp = solrServer.ping();
27
			final SolrPingResponse rsp = client.ping();
28 28
			if (rsp.getStatus() != 0) {
29 29
				log.error("Invalid connection to solr Server (status = 0)");
30 30
				throw new CloudIndexClientException("Invalid connection to solr Server (status = 0)");
31 31
			}
32
			return new CloudIndexClient(solrServer);
32
			return new CloudIndexClient(client);
33 33
		} catch (Throwable e) {
34 34
			log.error("The initialization of indexClient is FAILED", e);
35 35
			throw new CloudIndexClientException("The initialization of indexClient is FAILED", e);

Also available in: Unified diff