Skip to content

Commit 0f63b16

Browse files
committed
core: fix NPE when NvramData is empty
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]>
1 parent 2fb96e7 commit 0f63b16

File tree

1 file changed

+1
-1
lines changed
  • backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao

1 file changed

+1
-1
lines changed

Diff for: backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDaoImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public List<String> getAllRunningNamesWithSpecificIsoAttached(Guid isoDiskId) {
413413

414414
private Pair<SecretValue<String>, String> getExternalData(Guid vmId, String functionName) {
415415
List<Pair<SecretValue<String>, String>> resultRows = getCallsHandler().executeReadList(functionName,
416-
(rs, i) -> new Pair<>(new SecretValue<String>(new String(rs.getString("data"))), rs.getString("hash")),
416+
(rs, i) -> new Pair<>(new SecretValue<String>(rs.getString("data")), rs.getString("hash")),
417417
getCustomMapSqlParameterSource().addValue("vm_id", vmId));
418418
if (resultRows.isEmpty()) {
419419
return new Pair<SecretValue<String>, String>();

0 commit comments

Comments
 (0)