PDF import keep merge dialog#15287
Conversation
Review Summary by QodoFix PDF import NPE and keep merge dialog open with single importer
WalkthroughsDescription• Replace Optional.of() with Optional.ofNullable() to safely handle null event handlers • Wrap event handlers in try/finally blocks to guarantee finishTask() execution • Use Objects.toString() to prevent null task titles from propagating to JavaFX • Reduce ACTIVE_COLUMNS_MINIMUM from 2 to 1 to keep merge dialog open with single importer Diagramflowchart LR
A["PDF Drag & Drop"] --> B["TaskNotification Created"]
B --> C["Event Handlers Registered"]
C --> D["Optional.ofNullable()"]
D --> E["Try/Finally Blocks"]
E --> F["finishTask() Guaranteed"]
C --> G["UiTaskExecutor.getJavaFXTask()"]
G --> H["Objects.toString() for Title"]
H --> I["No Null Propagation"]
B --> J["MultiMergeEntriesView"]
J --> K["ACTIVE_COLUMNS_MINIMUM = 1"]
K --> L["Dialog Stays Open"]
File Changes1. jabgui/src/main/java/org/jabref/gui/Notifications.java
|
Code Review by Qodo
1.
|
|
This works for any invalid PDF file as well. It doesn't give the NPE anymore. |
This comment has been minimized.
This comment has been minimized.
|
@calixtus merged your solution with the nullable eventhandlers as a hotfix at #15288. Current main doesn't trigger the exceptions in the GUI anymore, but they still show up in the log. I will try to get rid of that broken PDF. For the user it would be nice to know which PDF in particular triggers the exceptions. Maybe something for the integrity check. |
This comment has been minimized.
This comment has been minimized.
|
|
||
| ### Fixed | ||
|
|
||
| - We fixed PDF import and prevent NPE in TaskNotification and keep merge dialog open when only one importer succeeds. [#15283](https://github.com/JabRef/jabref/issues/15283) |
There was a problem hiding this comment.
Task notification was introduced after last release, so no changelog for that issue.
Don't mix separate issues in one pr and one changelog entry. Create a new pr for the merge dialog.
There was a problem hiding this comment.
Task notification was introduced after last release, so no changelog for that issue. Don't mix separate issues in one pr and one changelog entry. Create a new pr for the merge dialog.
Alright I'll strip out the Notifications.java and UiTaskExecutor.java changes since those are now covered by #15288 and open a separate focused PR for just the MultiMergeEntriesView.java change that fixes #15127.
There was a problem hiding this comment.
I ended up rebasing the code onto main and just stripped out the changes that were already covered by #15288. I can create a new PR as well if that would be cleaner but I did force push the changes onto this branch and I'll update PR description as well. Let me know however works best for you to review.
✅ All tests passed ✅🏷️ Commit: bd7c8dd Learn more about TestLens at testlens.app. |
|
Hey, we noticed that you force-pushed your changes. Force pushing is a bad practice when working together on a project (mainly because it is not supported well by GitHub itself). Commits are lost and comments on commits lose their context, thus making it harder to review changes. When the pull request is getting integrated into In future, please avoid that. For now, you can continue working. |
|
Can you please adapt the title of the PR? |
* upstream/main: (59 commits) Fix 15000 identifier (JabRef#15286) Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (JabRef#15305) Supress JavaFX VirtualFlow Info log noise for large libraries (10k+). (JabRef#15298) Chore(deps): Bump commons-logging:commons-logging in /versions (JabRef#15304) Fix merge dialog closing immediately when only one PDF importer returns metadata (JabRef#15127) (JabRef#15287) Fixed nullable eventhandlers (JabRef#15288) New Crowdin updates (JabRef#15285) Fix the ESC key for GlobalSearchResultDialog (JabRef#15259) Remove jbang plugin banner (JabRef#15282) Chore(deps): Bump org.apache.httpcomponents.core5:httpcore5 in /versions (JabRef#15281) Udpate to latest gradle master (JabRef#15279) Migrate to GemsFX Notifications (JabRef#14762) Chore(deps): Bump JetBrains/junie-github-action from 0 to 1 (JabRef#15272) Chore(deps): Bump docker/setup-qemu-action from 3 to 4 (JabRef#15269) Feature/citation count dropdown (JabRef#15216) Update dependency org.apache.maven.plugins:maven-resources-plugin to v3.5.0 (JabRef#15275) Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#15273) Fix more security Fix pr_body leakage Chore: add dependency-management.md (JabRef#15278) ...
Related issues and pull requests
Closes #15127
PR Description
When dragging and dropping a PDF into JabRef, the merge dialog was closing instantly before the user could interact with it which resulted in entries being created with only the filename and no metadata or DOI. The root cause was that MultiMergeEntriesView was configured with ACTIVE_COLUMNS_MINIMUM = 2 meaning the dialog would automatically close if fewer than 2 PDF importers returned metadata. For many valid PDFs only 1 importer like XMP succeeds, so the dialog was dismissing itself immediately.
This PR changes ACTIVE_COLUMNS_MINIMUM from 2 to 1 so the merge dialog stays open as long as at least one importer returns data. Only when zero sources succeed does it close and fall back to creating an empty entry with just the filename.
Note: The NullPointerException in Notifications.java that was also triggered during PDF import has already been fixed in main via hotfix #15288 by @calixtus.
Steps to test
15127.Test.mp4
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)