Skip to content

Fix NPE when importing old JabRef preferences#14597

Merged
calixtus merged 10 commits into
JabRef:mainfrom
pulkitbajaj:fix/import-preferences-npe
Dec 20, 2025
Merged

Fix NPE when importing old JabRef preferences#14597
calixtus merged 10 commits into
JabRef:mainfrom
pulkitbajaj:fix/import-preferences-npe

Conversation

@pulkitbajaj

@pulkitbajaj pulkitbajaj commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Closes #14497

Steps to test

  1. Download the JabRef.xml file provided in issue Import old jabref preferences fails with npe odel.metadata.UserHostInfo.getUserHostString #14497.
  2. Created a temporary JUnit test to reproduce the crash by calling new JabRefCliPreferences().getInternalPreferences().
  3. Verified that the test failed with a NullPointerException before the fix.
  4. Verified that the test passed successfully after applying the fix.

Mandatory checks


AI Disclosure: I used an AI assistant to help analyze the stack trace, understand the root cause (NullPointerException), and draft the reproduction test case. I manually verified the fix and the test results.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @pulkitbajaj! 👋

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.

@github-actions github-actions Bot added first contrib good first issue An issue intended for project-newcomers. Varies in difficulty. status: changes-required Pull requests that are not yet complete labels Dec 13, 2025
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 16, 2025
@calixtus calixtus requested a review from koppor December 17, 2025 00:10
defaults.put(VERSION_IGNORED_UPDATE, "");
defaults.put(VERSION_CHECK_ENABLED, Boolean.TRUE);

Localization.setLanguage(getLanguage());

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.

Why this was moved? Why not the comments?

I think, this should be kept as is?!?!?!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved this to the end of the constructor to ensure that the defaults map is fully populated before getLanguage() is called. In original version, calling it so early (before initialization was complete) contributed to the NullPointerException/initialization issues we saw.
You are right about the comments-I should have moved them down along with the code. I can move the comments to line 717 to match the code location. Would that resolve the concern?

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.

Please move the comments, too

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.

defaults map is to be removed anyways as soon as #14400 is finished, so that issue with a non populated defaults map is probably something that might be a deeper issue - or a non-issue. However, move fast.

@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 17, 2025
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 20, 2025
@github-actions github-actions Bot added the status: changes-required Pull requests that are not yet complete label Dec 20, 2025
calixtus and others added 3 commits December 20, 2025 12:07
@github-actions github-actions Bot removed the status: changes-required Pull requests that are not yet complete label Dec 20, 2025
@koppor koppor enabled auto-merge December 20, 2025 12:20
@koppor koppor added this pull request to the merge queue Dec 20, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 20, 2025
@calixtus calixtus enabled auto-merge December 20, 2025 14:42
@calixtus calixtus added this pull request to the merge queue Dec 20, 2025
Merged via the queue into JabRef:main with commit 2cf1b65 Dec 20, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: preferences first contrib good first issue An issue intended for project-newcomers. Varies in difficulty.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants