Do we need to close elastic search client when an exception is thrown?

315 views Asked by At

I've currently a piece of code which closes elastic search client when an exception is throw in the update request.

Like this:

         static Client client;
         try{
         .....async update which causes document missing

         }catch(InterruptedException|ExecutionException exception){
             client.close()
         }

But that will cause client to not available for other requests also unless instantiated again.

My question is does this clean up required on client object? Should I need to close this? Will be there be any resources intact for that failed requests if I don't close the elastic search client? Or is there any way I can make clean without needing to close the client object?

0

There are 0 answers