-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix closing of JabRef in case of issues with index writer #10840
Conversation
Uncaught exception occurred in Thread[#60,JavaFX Application Thread,5,main] java.lang.NullPointerException: Cannot invoke "org.apache.lucene.index.IndexWriter.close()" because "this.indexWriter" is null at org.jabref@100.0.0/org.jabref.logic.pdf.search.PdfIndexer.close(PdfIndexer.java:299) at org.jabref@100.0.0/org.jabref.logic.pdf.search.PdfIndexerManager.shutdownIndexer(PdfIndexerManager.java:74) at org.jabref@100.0.0/org.jabref.gui.LibraryTab.onClosed(LibraryTab.java:792)
Not really happy. Why is indexDirectory null? |
private IndexReader reader; | ||
|
||
private PdfIndexer(BibDatabaseContext databaseContext, Directory indexDirectory, FilePreferences filePreferences) { | ||
this.databaseContext = databaseContext; | ||
this.indexDirectory = indexDirectory; | ||
if (indexDirectory == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the code. Especially org.jabref.model.database.BibDatabaseContext#getFulltextIndexPath
. That never returns null.
Proposal: Ship that code and "check" if at some persons report that output. (Line 67). Then, we can track down the issue.
Added some comments. Should good to go now. |
The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build. |
@@ -45,16 +48,34 @@ public class PdfIndexer { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(PdfIndexer.class); | |||
|
|||
@VisibleForTesting | |||
@Nullable // null might happen if lock is held by another JabRef instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of this Nullable/non null annotations. Visible for testing is okay for me
* upstream/main: Bump org.apache.lucene:lucene-core from 9.9.1 to 9.9.2 (#10860) Bump org.junit.jupiter:junit-jupiter from 5.10.1 to 5.10.2 (#10863) Bump org.apache.lucene:lucene-highlighter from 9.9.1 to 9.9.2 (#10861) Bump org.tinylog:tinylog-api from 2.6.2 to 2.7.0 (#10862) Bump org.apache.lucene:lucene-queryparser from 9.9.1 to 9.9.2 (#10859) Bump gradle/wrapper-validation-action from 1 to 2 (#10858) Bump codecov/codecov-action from 3 to 4 (#10857) Bump peter-evans/create-pull-request from 5 to 6 (#10856) Update Gradle Wrapper from 8.5 to 8.6. (#10854) Enable auto merge of gradle wrapper update Jump to entry from cli (#10578) Fix closing of JabRef in case of issues with index writer (#10840) Update deployment-arm64.yml Fix secrents presence chcek
* upstream/main: (68 commits) BibTeX 'Title' to MS Office 'Publicationtitle' field (JabRef#10864) Introduce BibliographyConsistencyCheckResultTxtWriter (JabRef#10847) Upgrade gradle-build-action to actions/setup-gradle (JabRef#10866) Bump org.apache.lucene:lucene-core from 9.9.1 to 9.9.2 (JabRef#10860) Bump org.junit.jupiter:junit-jupiter from 5.10.1 to 5.10.2 (JabRef#10863) Bump org.apache.lucene:lucene-highlighter from 9.9.1 to 9.9.2 (JabRef#10861) Bump org.tinylog:tinylog-api from 2.6.2 to 2.7.0 (JabRef#10862) Bump org.apache.lucene:lucene-queryparser from 9.9.1 to 9.9.2 (JabRef#10859) Bump gradle/wrapper-validation-action from 1 to 2 (JabRef#10858) Bump codecov/codecov-action from 3 to 4 (JabRef#10857) Bump peter-evans/create-pull-request from 5 to 6 (JabRef#10856) Update Gradle Wrapper from 8.5 to 8.6. (JabRef#10854) Enable auto merge of gradle wrapper update Jump to entry from cli (JabRef#10578) Fix closing of JabRef in case of issues with index writer (JabRef#10840) Update deployment-arm64.yml use nio path fix submodules Fix secrents presence chcek Update deployment-arm64.yml ...
I started JabRef. Twice. Then, the same index is used for Lucene by the second instance. Does not work:
This PR adds a workaround by using
null
and Optionals.This also adds a workaround for #10781 by checking for
null
. The workaround is the first code... OK, we could also check why thenull
appears here. Sounded like bigger work for that excpetional case.This relates to #10841. The other PR is more on the loading task...
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)