Skip to content
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 NPE when saving preferences #11509

Merged
merged 2 commits into from
Jul 17, 2024
Merged

Conversation

LoayGhreeb
Copy link
Member

Follow-up to #11379.
An exception was thrown after changing "show preview as a tab" in the preferences.

Exception
ERROR: Uncaught exception occurred in Thread[#54,JavaFX Application Thread,5,main]: java.lang.NullPointerException: Cannot invoke "org.jabref.model.entry.BibEntry.getType()" because "entry" is null
	at [email protected]/org.jabref.gui.entryeditor.RequiredFieldsTab.determineFieldsToShow(RequiredFieldsTab.java:59)
	at [email protected]/org.jabref.gui.entryeditor.FieldsEditorTab.shouldShow(FieldsEditorTab.java:213)
	at [email protected]/org.jabref.gui.entryeditor.RequiredFieldsTab.shouldShow(RequiredFieldsTab.java:31)
	at [email protected]/org.jabref.gui.entryeditor.EntryEditor.lambda$adaptVisibleTabs$5(EntryEditor.java:352)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:178)
	at java.base/java.util.LinkedList$LLSpliterator.forEachRemaining(LinkedList.java:1249)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
	at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
	at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
	at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
	at [email protected]/org.jabref.gui.entryeditor.EntryEditor.adaptVisibleTabs(EntryEditor.java:352)
	at [email protected]/org.jabref.gui.entryeditor.EntryEditor.lambda$new$1(EntryEditor.java:151)
	at [email protected]/com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:372)
	at [email protected]/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91)
	at [email protected]/javafx.beans.property.BooleanPropertyBase.fireValueChangedEvent(BooleanPropertyBase.java:104)
	at [email protected]/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:111)
	at [email protected]/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
	at [email protected]/org.jabref.preferences.PreviewPreferences.setShowPreviewAsExtraTab(PreviewPreferences.java:101)
	at [email protected]/org.jabref.gui.preferences.preview.PreviewTabViewModel.storeSettings(PreviewTabViewModel.java:207)

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@Siedlerchr Siedlerchr added this pull request to the merge queue Jul 17, 2024
Merged via the queue into JabRef:main with commit ea00fe6 Jul 17, 2024
21 checks passed
@LoayGhreeb LoayGhreeb deleted the EntryEditorNPE branch July 17, 2024 18:59
@@ -386,6 +384,9 @@ public void setCurrentlyEditedEntry(BibEntry currentlyEditedEntry) {
getSelectedTab().notifyAboutFocus(currentlyEditedEntry);
});

EasyBind.listen(preferencesService.getPreviewPreferences().showPreviewAsExtraTabProperty(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if this decreases performance and increase memory consumption -- IMHO the old binding should be removed. I don't know if this possible (or if this is an issue at all...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that the binding will be added every time. One solution is to revert this commit and check if currentlyEditedEntry is not null in adaptVisibleTabs(). Or, keep this commit but add a new boolean to track if the binding is registered or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that the binding will be added every time. One solution is to revert this commit and check if currentlyEditedEntry is not null in adaptVisibleTabs(). Or, keep this commit but add a new boolean to track if the binding is registered or not.

I was hoping for another way. Also to apply for the other binding creations in the same method.

LoayGhreeb added a commit to LoayGhreeb/jabref that referenced this pull request Jul 18, 2024
@LoayGhreeb LoayGhreeb mentioned this pull request Jul 18, 2024
6 tasks
github-merge-queue bot pushed a commit that referenced this pull request Jul 19, 2024
* Revert "Fix NPE when saving preferences (#11509)"

This reverts commit ea00fe6.

* Fix NPE when saving preferences

* Update CHANGELOG.md
Siedlerchr added a commit to subhramit/jabref that referenced this pull request Jul 19, 2024
* upstream/main:
  Fix NPE when saving preferences (JabRef#11509)
  Switch to stream-based loading (JabRef#11479)
  Save unlinked local files dialog prefs (JabRef#11493)
  Add minimal support for biblatex data annotations (JabRef#11506)
  Fix handling of relative-file storage and auto linking (JabRef#11492)
  New Crowdin updates (JabRef#11504)
  Add missing issue numbers
  CSL4LibreOffice - A [GSoC '24] (JabRef#11477)
  Bump src/main/resources/csl-styles from `b2be5ae` to `fd6cb3e` (JabRef#11501)
  Bump gittools/actions from 1.1.1 to 1.2.0 (JabRef#11500)
  Bump com.kohlschutter.junixsocket:junixsocket-core from 2.9.1 to 2.10.0 (JabRef#11498)
  Bump commons-logging:commons-logging from 1.3.2 to 1.3.3 (JabRef#11499)
  Bump org.jsoup:jsoup from 1.17.2 to 1.18.1 (JabRef#11497)
  Bump com.kohlschutter.junixsocket:junixsocket-mysql from 2.9.1 to 2.10.0 (JabRef#11496)
  Bump org.openrewrite.recipe:rewrite-recipe-bom from 2.14.0 to 2.15.0 (JabRef#11495)
  FAQ updates (JabRef#11486)
  Update Gradle Wrapper from 8.8 to 8.9.
  Fix Chocolate.bib (JabRef#11491)

# Conflicts:
#	src/main/java/org/jabref/gui/openoffice/OOBibBase.java
#	src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java
#	src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
#	src/main/java/org/jabref/gui/openoffice/StyleSelectDialogViewModel.java
#	src/main/java/org/jabref/preferences/JabRefPreferences.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants