Skip to content

Fix not on fx thread exceptions for cleanup and cite key generator#15424

Merged
Siedlerchr merged 4 commits into
mainfrom
fixUIExceptions
Mar 26, 2026
Merged

Fix not on fx thread exceptions for cleanup and cite key generator#15424
Siedlerchr merged 4 commits into
mainfrom
fixUIExceptions

Conversation

@Siedlerchr

@Siedlerchr Siedlerchr commented Mar 25, 2026

Copy link
Copy Markdown
Member

Related issues and pull requests

Closes #15366
Closes https://github.com/JabRef/jabref-issue-melting-pot/issues/1165

PR Description

Key problem is that mutations to bib entry are not on FX thread in certain places but we have UI bound listeners that interact based on the field data

Introduced a callback to fix this and split up

Used Claude to implement the changes

Steps to test

  1. Generate citation key

  2. Run cleanup operations

  3. Do not see any exceptions

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [.] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix threading exceptions in citation key generation and cleanup operations

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Fix "not on FX thread" exceptions in citation key generation and cleanup operations
• Separate expensive computations from field mutations using callback scheduler
• Route BibEntry field mutations to JavaFX thread via UiTaskExecutor
• Add mutationScheduler parameter to CleanupJob interface for thread-safe mutations
Diagram
flowchart LR
  A["Background Thread<br/>Computation"] -->|"expensive logic"| B["Mutation Scheduler<br/>Callback"]
  B -->|"field mutations"| C["FX Thread<br/>ObservableMap Updates"]
  C -->|"fires listeners"| D["UI Listeners<br/>Safe Execution"]
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java 🐞 Bug fix +9/-2

Split key generation from FX thread mutation

jabgui/src/main/java/org/jabref/gui/citationkeypattern/GenerateCitationKeyAction.java


2. jabgui/src/main/java/org/jabref/gui/cleanup/CleanupDialogViewModel.java 🐞 Bug fix +11/-4

Add mutation scheduler callback to cleanup operations

jabgui/src/main/java/org/jabref/gui/cleanup/CleanupDialogViewModel.java


3. jablib/src/main/java/org/jabref/logic/cleanup/CleanupJob.java ✨ Enhancement +17/-0

Add overloaded cleanup method with mutation scheduler

jablib/src/main/java/org/jabref/logic/cleanup/CleanupJob.java


View more (6)
4. jablib/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java ✨ Enhancement +11/-1

Route cleanup mutations through scheduler parameter

jablib/src/main/java/org/jabref/logic/cleanup/CleanupWorker.java


5. jablib/src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanup.java 🐞 Bug fix +28/-18

Dispatch field mutations via scheduler, keep formatting on background thread

jablib/src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanup.java


6. jablib/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java ✨ Enhancement +7/-0

Override scheduler method to bypass for file I/O operations

jablib/src/main/java/org/jabref/logic/cleanup/MoveFilesCleanup.java


7. jablib/src/main/java/org/jabref/logic/cleanup/NormalizeWhitespacesCleanup.java 🐞 Bug fix +9/-1

Dispatch whitespace normalization mutations through scheduler

jablib/src/main/java/org/jabref/logic/cleanup/NormalizeWhitespacesCleanup.java


8. jablib/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java ✨ Enhancement +7/-0

Override scheduler method to bypass for file I/O operations

jablib/src/main/java/org/jabref/logic/cleanup/RenamePdfCleanup.java


9. CHANGELOG.md 📝 Documentation +1/-0

Document fix for threading exceptions on macOS

CHANGELOG.md


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Looking for bugs?

Check back in a few minutes. An AI review agent is analyzing this pull request.

Grey Divider

Qodo Logo

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 25, 2026
@testlens-app

This comment has been minimized.

@testlens-app

testlens-app Bot commented Mar 26, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: ed79df7
▶️ Tests: 10203 executed
⚪️ Checks: 58/58 completed


Learn more about TestLens at testlens.app.

@Siedlerchr Siedlerchr enabled auto-merge March 26, 2026 17:54

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving as no pending comments/requests

@Siedlerchr Siedlerchr added this pull request to the merge queue Mar 26, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Mar 26, 2026
Merged via the queue into main with commit 715b009 Mar 26, 2026
59 checks passed
@Siedlerchr Siedlerchr deleted the fixUIExceptions branch March 26, 2026 18:36
jadegold55 pushed a commit to jadegold55/jabref that referenced this pull request Mar 26, 2026
…abRef#15424)

* Fix not on fx thread exception in citation key generator

* Fix not on fx thread exception in citation key generator and cleanup

Use callback to run changes on fx thread

* checkstyle

* remove comment
Siedlerchr added a commit to geovani-rocha/jabref that referenced this pull request Mar 28, 2026
…o fix-group-icons

* 'fix-group-icons' of github.com:geovani-rocha/jabref: (26 commits)
  chore(deps): update dependency org.apache.logging.log4j:log4j-to-slf4j to v2.25.4 (JabRef#15436)
  chore(deps): update jackson monorepo to v3.1.1 (JabRef#15435)
  Fix PushToPreferences reset and import (JabRef#15395)
  Add fulltext fetcher for Wiley via their TDM API (JabRef#15388)
  Embed in-text nature in reference marks for CSL citations (JabRef#15381)
  Chore(deps): Bump com.gradleup.shadow:shadow-gradle-plugin (JabRef#15430)
  Fix not on fx thread exceptions for cleanup and cite key generator (JabRef#15424)
  Revert "Update gradle to nightly of 2026-03-23 (JabRef#15372)"
  feat: add benchmarks for Lucene fulltext search and linked file indexing, including setup and teardown of the index. (JabRef#15385)
  Chore(deps): Bump org.openrewrite.recipe:rewrite-recipe-bom (JabRef#15418)
  Add claude gitignore (JabRef#15413)
  Fix group filter icon in side pane (JabRef#15408)
  Add new prs_link feature
  Chore(deps): Bump org.glassfish.hk2:hk2-api in /versions (JabRef#15422)
  Chore(deps): Bump org.openrewrite.rewrite from 7.28.2 to 7.29.0 (JabRef#15419)
  Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#15417)
  Fix for inconsistent "hide tab bar" behavior (JabRef#15409)
  Update dependency org.glassfish.hk2:hk2-utils to v4 (JabRef#15407)
  Persist file notifications (JabRef#15403)
  Update dependency org.glassfish.hk2:hk2-locator to v4 (JabRef#15405)
  ...
Ranjeet2702 pushed a commit to Ranjeet2702/jabref that referenced this pull request Apr 14, 2026
…abRef#15424)

* Fix not on fx thread exception in citation key generator

* Fix not on fx thread exception in citation key generator and cleanup

Use callback to run changes on fx thread

* checkstyle

* remove comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Quality → Clean up entries" blocks the process (repeated exception pop-up windows)

3 participants