On 10/17/2014 12:47 AM, devraj.jaiman wrote:
HttpSolrServer server = null;
if (httpClient == null) {
server = new HttpSolrServer(url);
httpClient = server.getHttpClient();
} else {
server = new HttpSolrServer(url, httpClient);
}
and httpClient is same as previous. But whenever its creating second
connection or say executing else block giving exceptions (i.e. Client was
created outside of HttpSolrServer.)
If you want all your objects to use the same HttpClient, I would create
it outside of HttpSolrServer entirely.
Here's how I manage a shared httpclient object and multiple
HttpSolrServer objects. This is using 4.x versions of SolrJ:
http://apaste.info/GDJ
The thread synchronization is only important if you have any possibility
of creating objects in parallel. I have no idea how this class might be
used in the future, so I wanted to give it protection against thread
problems.
Thanks,
Shawn