I'm using ES and Transport 5.5.2 and getting an NPE thrown when closing the transport client:
// Shut down existing client if open
if (client != null) {
logger.info("Detected open Transport client - closing it");
try {
client.close();
if (client.threadPool() != null)
client.threadPool().shutdown();
} catch (Exception e) {
String message = "An exception was thrown when attempting to close the Transport client: ";
logger.error(message, e);
Here's what that logger entry in the last line produces:
message: An exception was thrown when attempting to close the Transport client: stack_trace: java.lang.NullPointerException: null
Note that the client and threadpool objects themselves aren't null since I'm checking for null so it seems to be something internal to either TransportClient.close() or ThreadPool.shutdown() that's causing this.
Thanks @dadoonet. I think it was in documentation somewhere. I can remove that. Do you think that could be causing the problem? i.e. we are trying to close the thread pool after it has already been closed (and nullified?) by the call to TransportClient.close()?
Thanks for the pointer @dadoonet. Removing the code that was closing the threadpools manually got rid of the NPE. But now I'm seeing an IllegalStateException when I call TransportClient.close():
java.lang.IllegalStateException: thread was not started
at io.netty.util.concurrent.GlobalEventExecutor.awaitInactivity(GlobalEventExecutor.java:197)
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.close(PreBuiltXPackTransportClient.java:63)
Actually, that is what I'm calling. Not doing a static call to TransportClient.close(). Just wanted to be clear what class I was making that call against. I have a variable client of type TransportClient that I'm calling close on as you've suggested: client.close().
Actually, that thought had crossed my mind (one tries to close it after another has already done so results in that "thread was not started" illegal state) and, now that you mention it, I'm pretty sure that's what's happening
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.