// close and read are synchronized because can not call close on the data source while it is in // use // this could lead to the case where file iterators that are in use by a thread are returned // to the pool... this would be bad public boolean close() { options.getInterruptFlag().set(true); boolean obtainedLock = false; try { obtainedLock = scannerSemaphore.tryAcquire(10, TimeUnit.MILLISECONDS); if (!obtainedLock) return false; scanClosed = true; if (isolatedDataSource != null) isolatedDataSource.close(false); } catch (InterruptedException e) { return false; } finally { if (obtainedLock) scannerSemaphore.release(); } return true; }