Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential NPE in MmapByteBufferService #181

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

rolnico
Copy link
Member

@rolnico rolnico commented Nov 7, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Bug fix

What is the current behavior?
In MmapByteBufferService.tryToDelete(), context.file can be null, which will throw a NullPointerException when trying to delete the file

What is the new behavior (if this is a feature change)?
We now check first if context.file is null or not

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

Signed-off-by: Nicolas Rol <[email protected]>
@rolnico rolnico requested a review from olperr1 November 7, 2024 12:15
Comment on lines 128 to 129
} catch (Exception e) {
LOGGER.trace(e.toString(), e);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (Exception e) {
LOGGER.trace(e.toString(), e);
} catch (IOException e) {
throw new UncheckedIOException(e);

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok for the IOException but we don't want to throw an exception if we fail to delete the file, just log it and return false

Signed-off-by: Nicolas Rol <[email protected]>
@rolnico rolnico marked this pull request as draft November 7, 2024 12:51
@rolnico rolnico marked this pull request as ready for review November 7, 2024 12:51
Copy link

sonarcloud bot commented Nov 7, 2024

Copy link

sonarcloud bot commented Nov 7, 2024

@rolnico rolnico merged commit 21929f8 into main Nov 7, 2024
12 checks passed
@rolnico rolnico deleted the nro/fix_npe_in_mmapbytebufferservice branch November 7, 2024 13:52
rolnico added a commit that referenced this pull request Nov 7, 2024
* fix potential NPE

Signed-off-by: Nicolas Rol <[email protected]>

* back to catching IOException

Signed-off-by: Nicolas Rol <[email protected]>

---------

Signed-off-by: Nicolas Rol <[email protected]>
(cherry picked from commit 21929f8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants