datastore is not closing always
Opened this issue · 0 comments
Hi Team, there is an issue with current code version. I am trying to close datastore from an app context destroy and current close method is not working properly.
The class ScheduledExecutorService is used and the datastore close method is trying to close it with this line: executor.shutdown();
However, it is not working and as there is a non-deamon thread alive the jvm process cannot finish. In my case, my webapp does not stop when I stop tomcat. So tomcat does not stop neither. Eventually, I have to kill jvm process to shutdown.
The fix may be to close it in this way:
try{
executor.shutdown();
if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
}catch(InterruptedException ie){
executor.shutdownNow();
Thread.currentThread().interrupt();
}
Above code worked in my case. You can double check how to close it from this java doc:
ExecutorService
Kind regards,
Pablo