Skip to content

core: fix NPE when NvramData is empty #1005

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

dupondje
Copy link
Member

When the is a NvramData row in the db, but without data, the getExternalData() call fails with a NPE:
ERROR [org.ovirt.engine.core.bll.HasNvramDataQuery] (default task-179) [4e047baa-c81c-4673-9cd2-6984d0e7477f] Exception: java.lang.NullPointerException
at java.base/java.lang.String.(String.java:236)
at org.ovirt.engine.core.dal//org.ovirt.engine.core.dao.VmDaoImpl.lambda$getExternalData$6(VmDaoImpl.java:416)

This because 'new String(null)' gives this NPE.
As we don't need to call 'new' here, just remove it to fix the issue.

Fixes issue # (delete if not relevant)

Changes introduced with this PR

Are you the owner of the code you are sending in, or do you have permission of the owner?

[y]

When the is a NvramData row in the db, but without data, the
getExternalData() call fails with a NPE:
ERROR [org.ovirt.engine.core.bll.HasNvramDataQuery] (default task-179) [4e047baa-c81c-4673-9cd2-6984d0e7477f] Exception: java.lang.NullPointerException
	at java.base/java.lang.String.<init>(String.java:236)
	at org.ovirt.engine.core.dal//org.ovirt.engine.core.dao.VmDaoImpl.lambda$getExternalData$6(VmDaoImpl.java:416)

This because 'new String(null)' gives this NPE.
As we don't need to call 'new' here, just remove it to fix the issue.

Signed-off-by: Jean-Louis Dupond <[email protected]>
@dupondje dupondje self-assigned this Mar 31, 2025
Copy link
Contributor

@JasperB-TeamBlue JasperB-TeamBlue left a comment

Choose a reason for hiding this comment

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

LGTM

@oVirt oVirt deleted a comment from Twilight-Computer Apr 9, 2025
@oVirt oVirt deleted a comment from Twilight-Computer Apr 9, 2025
@oVirt oVirt deleted a comment from Twilight-Computer Apr 9, 2025
@dupondje dupondje merged commit 84c9c95 into oVirt:master Apr 17, 2025
2 checks passed
@dupondje dupondje deleted the fix_npe_externaldata branch April 17, 2025 10:42
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