Just a try block or a try-with-resources block? I.e.

try (CloudSolrClient csc = new ClousSolrClient.....) {
}

try-with-resources is _designed_ to call close when the
block is exited, there's no mystery involved at all.

Best,
Erick

On Wed, Jul 4, 2018 at 10:13 PM, Ritesh Kumar
<ritesh.ku...@hotwaxsystems.com> wrote:
> Hello Shawn,
>
> I wasn't explicitly closing the client object but I fetched the client
> object inside the try block and this seems to automatically destroy the
> client object.
>
> Taking it out of the try block worked like magic.
>
> Problem solved!
>
> Best
>
> On Wed, Jul 4, 2018 at 10:40 PM Shawn Heisey <apa...@elyograg.org> wrote:
>
>> On 7/4/2018 2:41 AM, Ritesh Kumar wrote:
>> > I did exactly as you told, created a public static synchronized method.
>> The
>> > problem still exists.
>>
>> I wasn't addressing the connection problem.  I was addressing the
>> question in the subject -- one client object that you can use
>> everywhere.  But I think the problem you're having now is different than
>> the initial problem, based on the error message:
>>
>> > Maybe returning the client object if it is not null is causing
>> > " java.lang.IllegalStateException: Connection pool shut down" error. It
>> > does run fine for just one time.
>>
>> This means that you are still calling client.close() after you use the
>> client.  That must be removed.  The entire point of the close() call is
>> to release the internal objects to garbage and make the client unusable.
>>
>> Thanks,
>> Shawn
>>
>>

Reply via email to