ctubbsii commented on a change in pull request #1818:
URL: https://github.com/apache/accumulo/pull/1818#discussion_r543558569



##########
File path: 
core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReader.java
##########
@@ -72,16 +72,15 @@ protected TabletServerBatchReader(ClientContext context, 
Class<?> scopeClass, Ta
 
     queryThreadPool = ThreadPools.getFixedThreadPool(numQueryThreads,
         "batch scanner " + batchReaderInstance + "-", false);
+    // Call shutdown on this thread pool in case the caller does not call 
close().
     cleanable = CleanerUtil.shutdownThreadPoolExecutor(queryThreadPool, log);
   }
 
   @Override
   public void close() {
     if (closed.compareAndSet(false, true)) {
-      // deregister cleanable, but it won't run because it checks
-      // the value of closed first, which is now true
-      cleanable.clean();
       queryThreadPool.shutdownNow();
+      cleanable.clean();

Review comment:
       > In the next commit I left the order of calls the same. If we only use 
`cleanable.clean()` or put `cleanable.clean()` first, then we will always get 
the WARN log message: ThreadPoolExecutor found unreferenced without calling 
shutdown() or shutdownNow().
   
   If shutdown is only called in the close method, then it can be guarded with 
the closed variable that you are now passing to the cleaner. I guess what I 
don't know is if we ever want to call shutdown while leaving the containing 
object unclosed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to