Skip to content

Commit

Permalink
Fix NPE when opening and re-opening a library (JabRef#10763)
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored Jan 9, 2024
1 parent b45cc01 commit 5636ad0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/pdf/search/PdfIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private void addToIndex(BibEntry entry, LinkedFile linkedFile, boolean shouldCom
*/
public Set<String> getListOfFilePaths() {
Set<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5636ad0

Please sign in to comment.