/** * Get the searcher at the given position. * * <p>If the searcher's backing directory no longer exists, then close and disable it. A null * entry will then exist at the given index. */ public Searcher get(int index) { Searcher result = index < size() ? searchers.get(index) : null; if (result != null) { if (!result.getDirPath().exists()) { // disable index that has disappeared. searchers.set(index, null); if (index < clusterSearchers.size()) clusterSearchers.set(index, null); else extraSearchers.set(index - clusterSearchers.size(), null); try { result.close(); } catch (IOException e) { System.err.println( new Date() + ": WARNING : MultiSearcher couldn't close disappeared index at '" + result.getDirPath() + "'!"); e.printStackTrace(System.err); } result = null; } } return result; }
public void close() { if (isClosed.compareAndSet(false, true)) { for (Searcher searcher : searchers) { if (searcher != null) { try { searcher.close(); } catch (IOException e) { System.err.println( new Date() + ": *** WARNING: " + luceneId + " unable to close searcher '" + searcher.getDirPath() + "'!"); } } } } }