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

Eliminating possible NPE + adding safer try--with-resources version + small code cleanup #364

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

ole4ryb
Copy link
Contributor

@ole4ryb ole4ryb commented Nov 7, 2023

What

Methods in mappers return null which potentially can cause NPE, also there is a safer version of try-catch introduced: try-with-resources

Why

When method returns null instead of an empty collection it will propagate nulls into other places in code and can potentially trigger NPE. It is better and safer to return an empty collection. Also, try-with-resources will make sure that the steam will be always closed not matter what.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Internal change (non-breaking change with no effect on the functionality affecting end users)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the Changelog with details of my change in the UNRELEASED section if this change will affect end users
  • A corresponding change has been made to the Mapping Documentation repository

@ole4ryb ole4ryb changed the title Eliminating possible NPE + small code cleanup Eliminating possible NPE + safer try-catch version + small code cleanup Nov 7, 2023
@ole4ryb ole4ryb changed the title Eliminating possible NPE + safer try-catch version + small code cleanup Eliminating possible NPE + adding safer try--with-resources version + small code cleanup Nov 7, 2023
@ole4ryb ole4ryb merged commit 1e609dc into main Nov 7, 2023
1 check passed
@ole4ryb ole4ryb deleted the mitigate-potential-npe branch November 7, 2023 16:40
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.

2 participants