diff --git a/src/main/java/org/jabref/logic/pdf/search/PdfIndexer.java b/src/main/java/org/jabref/logic/pdf/search/PdfIndexer.java index a973831e134..d28f33b6507 100644 --- a/src/main/java/org/jabref/logic/pdf/search/PdfIndexer.java +++ b/src/main/java/org/jabref/logic/pdf/search/PdfIndexer.java @@ -280,7 +280,7 @@ private void addToIndex(BibEntry entry, LinkedFile linkedFile, boolean shouldCom */ public Set getListOfFilePaths() { Set paths = new HashSet<>(); - try (IndexReader reader = DirectoryReader.open(indexWriter)) { + try (IndexReader reader = DirectoryReader.open(getIndexWriter())) { IndexSearcher searcher = new IndexSearcher(reader); MatchAllDocsQuery query = new MatchAllDocsQuery(); TopDocs allDocs = searcher.search(query, Integer.MAX_VALUE); diff --git a/src/main/java/org/jabref/logic/pdf/search/PdfIndexerManager.java b/src/main/java/org/jabref/logic/pdf/search/PdfIndexerManager.java index 3f4bca38c49..8b620c015c9 100644 --- a/src/main/java/org/jabref/logic/pdf/search/PdfIndexerManager.java +++ b/src/main/java/org/jabref/logic/pdf/search/PdfIndexerManager.java @@ -62,16 +62,20 @@ public static void shutdownAllIndexers() { LOGGER.debug("Problem closing PDF indexer", e); } }); + indexerMap.clear(); + pathFilePreferencesMap.clear(); } public static void shutdownIndexer(BibDatabaseContext context) { - PdfIndexer indexer = indexerMap.get(context.getFulltextIndexPath()); + Path fulltextIndexPath = context.getFulltextIndexPath(); + PdfIndexer indexer = indexerMap.remove(fulltextIndexPath); if (indexer != null) { try { indexer.close(); } catch (IOException e) { LOGGER.debug("Could not close indexer", e); } + pathFilePreferencesMap.remove(fulltextIndexPath); } else { LOGGER.debug("No indexer found for context {}", context); }