Skip to content

Conversation

@subhash-dev-23
Copy link

…es (#14497)

Closes #14497

This PR fixes a NullPointerException that occurred when userAndHost was null during the initialization of InternalPreferences.
The fix ensures that the existing getUserHostInfo() method is used to safely initialize userAndHost, avoiding direct access to an uninitialized value.

Steps to test

  1. Launch JabRef in an environment where no userAndHost value has been initialized yet.

  2. Verify that JabRef starts without throwing a NullPointerException.

  3. Confirm that preference migrations complete successfully.

  4. Check the log to ensure no warnings or errors related to UserHostInfo initialization appear.

Mandatory checks

  • 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 described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • I checked the user 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 updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Hey @subhash-dev-23! 👋

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.

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.

Please re-check our AI Usage Policy to ensure that your pull request is in line with it. It also contains links to our contribution guide in case of any other doubts related to our contribution workflow.

CHANGELOG.md Outdated

### Fixed

- We fixed an issue where a NullPointerException was thrown when userAndHost was not initialized in the preferences. The initialization now correctly falls back to getUserHostInfo() to prevent the error. [#14497](https://github.com/JabRef/jabref/issues/14497)
Copy link
Member

Choose a reason for hiding this comment

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

Second sentence is an implementation detail. Maybe also shorten the first sentence, because NPE is unknown to the users. Think of a non-programmer using JabRef.

@koppor koppor added the status: changes-required Pull requests that are not yet complete label Dec 4, 2025
@jabref-machine
Copy link
Collaborator

You committed your code on the main brach of your fork. This is a bad practice. The right way is to branch out from main, work on your patch/feature in that new branch, and then get that branch merged via the pull request (see GitHub flow).

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.

@jabref-machine
Copy link
Collaborator

While the PR was in progress, a new version of JabRef has been released.

You have to merge upstream/main and move your entry in CHANGELOG.md up to the section ## [Unreleased].


## [Unreleased]

- Fixed a problem where JabRef could crash during startup if certain preference data was missing. [#14497](https://github.com/JabRef/jabref/issues/14497)
Copy link
Member

Choose a reason for hiding this comment

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

Please... Can you open the file for yourself and check the headings? Where do you think "Fixed" should belong to?

Hint in the screenshot

image

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

Labels

first contrib status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import old jabref preferences fails with npe odel.metadata.UserHostInfo.getUserHostString

4 participants