Source:
protected void executeVmCommand() { addCustomValue("InterfaceType", VmInterfaceType.forValue(getInterface().getType()).getDescription().toString()); boolean succeeded = false; boolean macAddedToPool = false; try { if (isVnicProfileChanged(oldIface, getInterface())) { Network newNetwork = networkHelper.getNetworkByVnicProfileId(getInterface().getVnicProfileId()); Network oldNetwork = networkHelper.getNetworkByVnicProfileId(oldIface.getVnicProfileId()); if (!Objects.equals(oldNetwork, newNetwork)) { externalNetworkManagerFactory.create(oldIface).deallocateIfExternal(); } } if (macShouldBeChanged) { macAddedToPool = addMacToPool(getMacAddress()); } if (mustChangeAddress(oldIface.getType(), getInterface().getType())) { vmDeviceDao.clearDeviceAddress(getInterface().getId()); } getInterface().setSpeed(VmInterfaceType.forValue(getInterface().getType()).getSpeed()); TransactionSupport.executeInNewTransaction(() -> { bumpVmVersion(); updatePassthoughDeviceIfNeeded(); getCompensationContext().snapshotEntity(oldIface); vmNicDao.update(getInterface()); getCompensationContext().stateChanged(); return null; }); succeeded = updateHost(); } finally { setSucceeded(succeeded); MacPool macPool = getMacPool(); if (macAddedToPool) { if (succeeded) { String macToRelease = oldIface.getMacAddress(); boolean stateless = getVm().isStateless(); boolean canReleaseOriginalMac = !stateless || !belongsToOriginalSnapshot(macToRelease); if (canReleaseOriginalMac) { macPool.freeMac(macToRelease); } } else { macPool.freeMac(getMacAddress()); } } } }

Target:
protected void executeVmCommand() { addCustomValue("InterfaceType", VmInterfaceType.forValue(getInterface().getType()).getDescription().toString()); boolean succeeded = false; boolean macAddedToPool = false; String macAddress = getMacAddress(); try { if (isVnicProfileChanged(oldIface, getInterface())) { Network newNetwork = networkHelper.getNetworkByVnicProfileId(getInterface().getVnicProfileId()); Network oldNetwork = networkHelper.getNetworkByVnicProfileId(oldIface.getVnicProfileId()); if (!Objects.equals(oldNetwork, newNetwork)) { externalNetworkManagerFactory.create(oldIface).deallocateIfExternal(); } } macAddedToPool = macShouldBeChanged && !belongsToOriginalSnapshot(macAddress) && addMacToPool(macAddress); if (mustChangeAddress(oldIface.getType(), getInterface().getType())) { vmDeviceDao.clearDeviceAddress(getInterface().getId()); } getInterface().setSpeed(VmInterfaceType.forValue(getInterface().getType()).getSpeed()); TransactionSupport.executeInNewTransaction(() -> { bumpVmVersion(); updatePassthoughDeviceIfNeeded(); getCompensationContext().snapshotEntity(oldIface); vmNicDao.update(getInterface()); saveNetworkFilterParameters(); getCompensationContext().stateChanged(); return null; }); succeeded = updateHost(); } finally { setSucceeded(succeeded); MacPool macPool = getMacPool(); if (macAddedToPool) { if (succeeded) { String macToRelease = oldIface.getMacAddress(); boolean isRunningStatelessVm = getVm().isStateless() && getVm().isRunning(); boolean canReleaseOriginalMac = !isRunningStatelessVm || !belongsToOriginalSnapshot(macToRelease); if (canReleaseOriginalMac) { macPool.freeMac(macToRelease); } } else { macPool.freeMac(macAddress); } } } }