ctubbsii commented on a change in pull request #1818:
URL: https://github.com/apache/accumulo/pull/1818#discussion_r556298849
##########
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:
The reason to ensure the cleanable is deregistered first, is because the
`shutdownNow()` could throw an exception, causing the cleanable to stick around
until the object is garbage collected. In general, we don't want cleanables to
stick around if they are going to be NOOPs later (the AtomicBoolean "closed"
variable will ensure it's a NOOP, so we don't try to close it both inside the
cleanable and outside).
----------------------------------------------------------------
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]