Skip to content

Commit bc06e4e

Browse files
committed
Add defensive check for instance host ID to prevent NPE
1 parent b37d94b commit bc06e4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ private boolean isPowerStateInSyncWithInstanceState(final VirtualMachine.PowerSt
11131113
if ((powerState == VirtualMachine.PowerState.PowerOff && instanceState == State.Running)
11141114
|| (powerState == VirtualMachine.PowerState.PowerOn && instanceState == State.Stopped)) {
11151115
HostVO instanceHost = hostDao.findById(instance.getHostId());
1116-
HostVO powerHost = powerHostId == instance.getHostId() ? instanceHost : hostDao.findById(powerHostId);
1116+
HostVO powerHost = instance.getHostId() != null && powerHostId == instance.getHostId() ? instanceHost : hostDao.findById(powerHostId);
11171117
logger.debug("VM: {} on host: {} and power host : {} is in {} state, but power state is {}",
11181118
instance, instanceHost, powerHost, instanceState, powerState);
11191119
return false;

0 commit comments

Comments
 (0)