Fix: Implement Preview Preferences reset and prevent NullPointerException (#14400)#14959
Fix: Implement Preview Preferences reset and prevent NullPointerException (#14400)#14959addix7 wants to merge 0 commit into
Conversation
|
Hey @addix7! 👋 Thank you for contributing to JabRef! We have automated checks in place, based on which you will soon get feedback if any of them are failing. We also use Qodo for review assistance. It will update your pull request description with a review help and offer suggestions to improve the pull request. After all automated checks pass, a maintainer will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs. You can read about the whole pull request process in our contribution guide. Please ensure that your pull request is in line with our AI Usage Policy and make necessary disclosures. |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
|
Hello again ! I'm aware of the 'main branch' warning and will use a dedicated branch for future PRs as suggested. Ready for review!" |
|
Hello again, |
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
| "\\begin{owncitation}<BR><BR><b>Own citation: </b>\\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + | ||
| "\\begin{comment}<BR><BR><b>Comment: </b>\\format[Markdown,HTMLChars(keepCurlyBraces)]{\\comment}\\end{comment}__NEWLINE__" + | ||
| "</font>__NEWLINE__"); | ||
| defaults.put(PREVIEW_STYLE, "<font face=\"sans-serif\">" + "<b>\\bibtextype</b><a name=\"\\citationkey\">\\begin{citationkey} (\\citationkey)</a>\\end{citationkey}__NEWLINE__" + "\\begin{author}<BR><BR>\\format[Authors(LastFirst, FullName,Sep= / ,LastSep= / ),HTMLChars]{\\author}\\end{author}__NEWLINE__" + "\\begin{editor & !author}<BR><BR>\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & !author}__NEWLINE__" + "\\begin{title}<BR><b>\\format[HTMLChars]{\\title}</b> \\end{title}__NEWLINE__" + "<BR>\\begin{date}\\date\\end{date}\\begin{edition}, \\edition. edition\\end{edition}__NEWLINE__" + "\\begin{editor & author}<BR><BR>\\format[Authors(LastFirst,FullName,Sep= / ,LastSep= / ),HTMLChars]{\\editor} (\\format[IfPlural(Eds.,Ed.)]{\\editor})\\end{editor & author}__NEWLINE__" + "\\begin{booktitle}<BR><i>\\format[HTMLChars]{\\booktitle}</i>\\end{booktitle}__NEWLINE__" + "\\begin{chapter} \\format[HTMLChars]{\\chapter}<BR>\\end{chapter}" + "\\begin{editor & !author}<BR>\\end{editor & !author}\\begin{!editor}<BR>\\end{!editor}\\begin{journal}<BR><i>\\format[HTMLChars]{\\journal}</i> \\end{journal} \\begin{volume}, Vol. \\volume\\end{volume}\\begin{series}<BR>\\format[HTMLChars]{\\series}\\end{series}\\begin{number}, No. \\format[HTMLChars]{\\number}\\end{number}__NEWLINE__" + "\\begin{school} \\format[HTMLChars]{\\school}, \\end{school}__NEWLINE__" + "\\begin{institution} <em>\\format[HTMLChars]{\\institution}, </em>\\end{institution}__NEWLINE__" + "\\begin{publisher}<BR>\\format[HTMLChars]{\\publisher}\\end{publisher}\\begin{location}: \\format[HTMLChars]{\\location} \\end{location}__NEWLINE__" + "\\begin{pages}<BR> p. \\format[FormatPagesForHTML]{\\pages}\\end{pages}__NEWLINE__" + "\\begin{abstract}<BR><BR><b>Abstract: </b>\\format[HTMLChars]{\\abstract} \\end{abstract}__NEWLINE__" + "\\begin{owncitation}<BR><BR><b>Own citation: </b>\\format[HTMLChars]{\\owncitation} \\end{owncitation}__NEWLINE__" + "\\begin{comment}<BR><BR><b>Comment: </b>\\format[Markdown,HTMLChars(keepCurlyBraces)]{\\comment}\\end{comment}__NEWLINE__" + "</font>__NEWLINE__"); |
There was a problem hiding this comment.
Unrelated code change. Strong sign of AI usage. Violating our policy.
|
Hello sir, @koppor But I want to assure you that i didnt use ai to reformat code, Instead I used IntelliJ Reformat File and optimise imports , i thought by using this, my code will clear the error |
|
i have manually undo the reformatting of both the files, but still some problem persists |
|
@addix7 you can just click on "Source Cod Tests / Checkstyle" and read the output https://github.com/JabRef/jabref/actions/runs/21581094928/job/62178433061?pr=14959
|
|
You committed your code on the For this pull request, this is OK. For subsequent pull requests, please start with a different branch with a proper branch name. See CONTRIBUTING.md for more details. |
|
Your code currently does not meet JabRef's code guidelines. IntelliJ auto format covers some cases. There seem to be issues with your code style and autoformat configuration. Please reformat your code (Ctrl+Alt+L) and commit, then push. |

User description
Closes #14400, #14410
Hello Jabref!!,
I am Kalp Pathak, 3rd semester cyberSecurity student. This is my first contribution to the project, and honestly, it was so amazing!
Firstly, since i never used jabref, to understand the problem, i compared it to youtube, I took youtube analogy to understand the problem.
During the initial phases of exploring the codebase, i everytime got a Null pointer exception, and i couldnt understand what wrong i was doing, i tried to implement a new layout, but later realised it was a template,
This is where youtube analogy helped, i realised that , resetting to null was like deleting the profile picture icon, and instead of a default grey picture we all get, i am trying to give nothing, ie null!!
Fix, was to not leave nothing(null), but instead, providing a default icon(again youtube analogy), ie give a Textbased preview layout object, inside which i can sett values to 0 or null.
I had the best time understanding this code,implementing the change, i am determined to learn more, so if you have any suggestions, feedback, please do let me know!,
i need guidance
obsession beats talent :)
Technical Changes:
PreviewPreferences.java: Added a private constructor to return a safe default state and updated setAll() to sync all properties, including the newly merged shouldDownloadCovers setting.
JabRefGuiPreferences.java: Updated the clear() method to utilize the new safe reset logic.
Steps to test
Open JabRef -> Options -> Preferences -> Entry preview.
Click the Reset button at the bottom.
Verification: The app should remain stable, and the layout should revert to default without any console errors or crashes.
Mandatory checks
CHANGELOG.mdPR Type
Bug fix, Enhancement
Description
Implement safe reset for PreviewPreferences to prevent NullPointerException
Add private constructor and getDefault() method for safe default state
Implement setAll() method to synchronize all preference properties
Update JabRefGuiPreferences.clear() to reset preview preferences safely
Fix ArrayList initialization in getPreviewLayouts for immutable list handling
Diagram Walkthrough
File Walkthrough
PreviewPreferences.java
Add safe default state and setAll synchronizationjabgui/src/main/java/org/jabref/gui/preview/PreviewPreferences.java
instance
including shouldDownloadCovers
JabRefGuiPreferences.java
Integrate preview preferences reset in clear methodjabgui/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java
call in clear() method
immutable list from getStringList()
button