Skip to content

Small cleanups and enhancements#15496

Merged
calixtus merged 3 commits into
mainfrom
enhance-errorhandling
Apr 4, 2026
Merged

Small cleanups and enhancements#15496
calixtus merged 3 commits into
mainfrom
enhance-errorhandling

Conversation

@calixtus

@calixtus calixtus commented Apr 4, 2026

Copy link
Copy Markdown
Member

Quick optimization

Related issues and pull requests

Refs #14762

PR Description

  • Reduced log level for unimportant messages
  • Removed leftover artifacts from previous notification migration
  • Enhanced error handling on clearing old search indices

Steps to test

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

@calixtus calixtus added dev: code-quality Issues related to code or architecture decisions status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Apr 4, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Enhance error handling and reduce log verbosity

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Enhanced error handling in search index clearing with proper resource management
• Reduced log level for non-critical messages to decrease console noise
• Removed unused imports and properties from GUI state manager
• Improved file deletion robustness with exception handling per file
Diagram
flowchart LR
  A["IndexManager<br/>clearOldSearchIndices"] -->|"Add try-catch<br/>per file deletion"| B["Improved<br/>Error Handling"]
  C["Log Level<br/>Reductions"] -->|"info to debug<br/>4 locations"| D["Reduced<br/>Console Noise"]
  E["Remove Unused<br/>Imports & Properties"] -->|"Clean up<br/>GUI State Manager"| F["Code<br/>Cleanup"]
  B --> G["Enhanced PR"]
  D --> G
  F --> G
Loading

Grey Divider

File Changes

1. jabgui/src/main/java/org/jabref/gui/JabRefGuiStateManager.java Code cleanup +1/-9

Remove unused imports and properties

• Removed unused imports: Bindings, BooleanBinding, ObjectProperty, SimpleObjectProperty,
 AutomaticFieldEditorUndoableEdit
• Deleted unused field properties: anyTaskRunning, tasksProgress, lastAutomaticFieldEditorEdit
• Changed log level from info to debug for "No open database detected" message

jabgui/src/main/java/org/jabref/gui/JabRefGuiStateManager.java


2. jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java Logging +2/-2

Reduce theme manager log verbosity

• Changed log level from info to debug for theme update messages (2 occurrences)
• Reduces console output for non-critical theme change notifications

jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java


3. jablib/src/main/java/org/jabref/logic/citationstyle/CSLStyleLoader.java Logging +1/-1

Reduce CSL style loader log level

• Changed log level from info to debug for "Loaded {} CSL styles" message
• Reduces console noise for routine style loading operations

jablib/src/main/java/org/jabref/logic/citationstyle/CSLStyleLoader.java


View more (2)
4. jablib/src/main/java/org/jabref/logic/search/IndexManager.java Error handling +20/-9

Enhance error handling in index clearing

• Removed unused import: java.io.File
• Added import: java.util.stream.Stream
• Enhanced clearOldSearchIndices() method with proper resource management using try-with-resources
 for Files.walk()
• Added per-file exception handling with Files.deleteIfExists() instead of File.delete()
• Added error logging for individual file deletion failures and directory read failures
• Improved variable naming from path to directory and file for clarity

jablib/src/main/java/org/jabref/logic/search/IndexManager.java


5. jablib/src/main/java/org/jabref/logic/search/PostgreServer.java Logging +1/-1

Reduce Postgres server log level

• Changed log level from info to debug for "Postgres server started" message
• Reduces console output for routine server startup notifications

jablib/src/main/java/org/jabref/logic/search/PostgreServer.java


Grey Divider

Qodo Logo

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

qodo-free-for-open-source-projects Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX Issues (0)

Grey Divider


Remediation recommended

1. Delete error log spam 🐞 Bug ➹ Performance
Description
IndexManager.clearOldSearchIndices now logs an ERROR (with stack trace) for every individual path
that cannot be deleted. Because this cleanup runs during GUI initialization, repeated deletion
failures in an index directory can generate very large logs and slow down startup.
Code

jablib/src/main/java/org/jabref/logic/search/IndexManager.java[R251-259]

+                    try (Stream<Path> indexPath = Files.walk(directory)) {
+                        indexPath.sorted(Comparator.reverseOrder())
+                                 .forEach(file -> {
+                                     try {
+                                         Files.deleteIfExists(file);
+                                     } catch (IOException e) {
+                                         LOGGER.error("Could not delete file {}", file, e);
+                                     }
+                                 });
Evidence
The per-file deletion loop logs at ERROR level inside the forEach, so a directory with many
undeletable files produces one ERROR+throwable per file. This method is invoked during application
initialization, so the impact occurs on every startup when the cleanup runs.

jablib/src/main/java/org/jabref/logic/search/IndexManager.java[233-268]
jabgui/src/main/java/org/jabref/gui/JabRefGUI.java[165-206]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`IndexManager.clearOldSearchIndices()` logs an `ERROR` (including stack trace) for every single file that fails to delete. When many files fail (e.g., locked/permission issues), this can flood logs and slow startup.

### Issue Context
This cleanup runs during `JabRefGUI.initialize()`, so the logging behavior affects startup performance and log signal-to-noise.

### Fix Focus Areas
- jablib/src/main/java/org/jabref/logic/search/IndexManager.java[251-262]
- jabgui/src/main/java/org/jabref/gui/JabRefGUI.java[185-186]

### Suggested fix approach
- Track failures while iterating (e.g., `AtomicInteger failedDeletes`, store first exception).
- Log **one** summary per directory at `WARN`/`ERROR` (e.g., "Failed to delete N paths under {dir}") and optionally log per-file failures at `DEBUG`.
- Alternatively, use `Files.walkFileTree` with a `FileVisitor` and consolidate failures into a single log message per directory.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@calixtus calixtus added this pull request to the merge queue Apr 4, 2026
@github-actions github-actions Bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Apr 4, 2026
Merged via the queue into main with commit 4ed2022 Apr 4, 2026
79 of 95 checks passed
@calixtus calixtus deleted the enhance-errorhandling branch April 4, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev: code-quality Issues related to code or architecture decisions 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.

2 participants