Skip to content

Patch: NullPointerException when accessing (absent) default CSL style file#11536

Merged
calixtus merged 1 commit into
JabRef:mainfrom
subhramit:oo-patch
Jul 26, 2024
Merged

Patch: NullPointerException when accessing (absent) default CSL style file#11536
calixtus merged 1 commit into
JabRef:mainfrom
subhramit:oo-patch

Conversation

@subhramit

@subhramit subhramit commented Jul 26, 2024

Copy link
Copy Markdown
Member

Addresses #11521 (comment)
If, in a development setup, csl-styles submodules are missing, NullPointerException is thrown when trying to access the default (ieee) style.

  • The try-catch block in context:
    try (InputStream inputStream = isExternalFile ? Files.newInputStream(internalFilePath) : CitationStyle.class.getResourceAsStream(internalFile)) {
    return createCitationStyleFromSource(inputStream, styleFile);
    } catch (NoSuchFileException e) {
    LOGGER.error("Could not find file: {}", styleFile, e);
    } catch (IOException e) {
    LOGGER.error("Error reading source file", e);
    }
    return Optional.empty();
    }

    is using try-with-resources, which automatically closes the InputStream. However, if getResourceAsStream returns null, no exception is thrown at this point. The null InputStream is passed to createCitationStyleFromSource. This has been modified to add a null check.
  • A null pointer exception has also been additionally caught and handled at the callee function createCitationStyleFromSource.

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked 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 to the documentation repository.

@subhramit subhramit mentioned this pull request Jul 26, 2024
6 tasks
@subhramit subhramit changed the title Patch: NullPointerException when accessing default CSL style file Patch: NullPointerException when accessing (absent) default CSL style file Jul 26, 2024
@subhramit subhramit added [outdated] type: bug Confirmed bugs or reports that are very likely to be bugs submodules labels Jul 26, 2024

@calixtus calixtus 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.

Lgtm

@Siedlerchr Siedlerchr added this pull request to the merge queue Jul 26, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 26, 2024
@calixtus calixtus added this pull request to the merge queue Jul 26, 2024
@Siedlerchr

Copy link
Copy Markdown
Member

sonatype is still down

@Siedlerchr

Copy link
Copy Markdown
Member

Merged via the queue into JabRef:main with commit 86d03dc Jul 26, 2024
@calixtus calixtus deleted the oo-patch branch July 26, 2024 14:36
@subhramit subhramit added this to the 6.0-alpha milestone Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: libre-office [outdated] type: bug Confirmed bugs or reports that are very likely to be bugs project: gsoc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants