@Override public void close() throws IOException { if (doClose) { IOUtils.close(primaryDir, secondaryDir); doClose = false; } }
@Override public void close() throws IOException { closed = true; IOUtils.close(writeLock); }
@Override public void close() throws IOException { try { IOUtils.close(fieldsStream, indexWriter, compressor); } finally { fieldsStream = null; indexWriter = null; compressor = null; } }
/** * Close the underlying {@link IndexInput}s. */ @Override public void close() throws IOException { if (!closed) { IOUtils.close(fieldsStream); closed = true; } }
@Override public void close() throws IOException { if (!closed) { IOUtils.close(vectorsStream); closed = true; } }
@Override public void close() throws IOException { IOUtils.close(toClose); } }
@Override public void close() throws IOException { try { IOUtils.close(vectorsStream, indexWriter); } finally { vectorsStream = null; indexWriter = null; } }
@Override public void close() throws IOException { IOUtils.close(handle); }
@Override public void close() throws IOException { IOUtils.close(docIn, posIn, payIn); }
@Override public void close() throws IOException { try { IOUtils.close(termsIn, postingsReader); } finally { // Clear so refs to terms index is GCable even if // app hangs onto us: fields.clear(); } }
@SuppressWarnings("try") void decRef() throws IOException { if (ref.decrementAndGet() == 0) { Throwable th = null; try (Closeable finalizer = this::notifyCoreClosedListeners){ IOUtils.close(termVectorsLocal, fieldsReaderLocal, fields, termVectorsReaderOrig, fieldsReaderOrig, cfsReader, normsProducer, pointsReader); } } }
@Override public void close() throws IOException { // Close all subs IOUtils.close(formats.values()); } }
@Override public void close() throws IOException { IOUtils.close(formats.values()); }
/** * Closes all given <tt>Closeable</tt>s. Some of the * <tt>Closeable</tt>s may be null; they are * ignored. After everything is closed, the method either * throws the first exception it hit while closing, or * completes normally if there were no exceptions. * * @param objects * objects to call <tt>close()</tt> on */ public static void close(Closeable... objects) throws IOException { close(Arrays.asList(objects)); }
@Override public void close() throws IOException { IOUtils.close(formats.values()); }
/** * Applies the consumer to all non-null elements in the collection even if an exception is thrown. The first exception * thrown by the consumer is re-thrown and subsequent exceptions are suppressed. */ public static <T> void applyToAll(Collection<T> collection, IOConsumer<T> consumer) throws IOException { IOUtils.close(collection.stream().filter(Objects::nonNull).map(t -> (Closeable) () -> consumer.accept(t))::iterator); }
/** * Creates a CharArraySet from a path. * * @param stopwords * the stopwords file to load * @return a CharArraySet containing the distinct stopwords from the given * file * @throws IOException * if loading the stopwords throws an {@link IOException} */ protected static CharArraySet loadStopwordSet(Path stopwords) throws IOException { Reader reader = null; try { reader = Files.newBufferedReader(stopwords, StandardCharsets.UTF_8); return WordlistLoader.getWordSet(reader); } finally { IOUtils.close(reader); } }
void flush(SegmentWriteState state, Sorter.DocMap sortMap) throws IOException { try { writer.finish(state.fieldInfos, state.segmentInfo.maxDoc()); } finally { IOUtils.close(writer); writer = null; } }
@Override public void close() throws IOException { IOUtils.close(() -> rld.release(reader), () -> onClose.accept(rld)); } }
@Override void flush(Map<String, TermsHashPerField> fieldsToFlush, final SegmentWriteState state, Sorter.DocMap sortMap) throws IOException { if (writer != null) { int numDocs = state.segmentInfo.maxDoc(); assert numDocs > 0; // At least one doc in this run had term vectors enabled try { fill(numDocs); assert state.segmentInfo != null; writer.finish(state.fieldInfos, numDocs); } finally { IOUtils.close(writer); writer = null; lastDocID = 0; hasVectors = false; } } }