From a9477be053d5f78b17dcd5290545efa1c024a825 Mon Sep 17 00:00:00 2001 From: alena Date: Wed, 4 May 2011 18:18:42 -0700 Subject: [PATCH] bug 9738: DB upgrade - fixed NPE happening during events migration status 9738: resolved fixed --- server/src/com/cloud/upgrade/dao/Upgrade218to22.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java index ba55d8f28b9..6be2e7c222d 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java @@ -266,7 +266,7 @@ public class Upgrade218to22 implements DbUpgrade { } insertNic(conn, guestNetworkId, domrId, running, guestMac, guestIp, guestNetmask, "Create", gateway, vnet, "DirectPodBasedNetworkGuru", true, 0, "Dhcp", null); - } else { + } else if (publicIp != null){ insertNic(conn, publicNetworkId, domrId, running, publicMac, publicIp, publicNetmask, "Create", gateway, publicVlan, "PublicNetworkGuru", true, 2, "Static", null); long controlNicId = insertNic(conn, controlNetworkId, domrId, running, privateMac, privateIp, privateNetmask, "Start", "169.254.0.1", null, "ControlNetworkGuru", false, 1, "Static", privateIp != null ? (domrId + privateIp) : null); @@ -2011,7 +2011,7 @@ public class Upgrade218to22 implements DbUpgrade { Properties snapEventParams = new Properties(); long snapId = -1L; long snapSize = -1L; - Long zoneId = null; + Long zoneId = 0L; UsageEventVO usageEvent = null; snapEventParams.load(new StringReader(event.getParameters())); @@ -2031,7 +2031,7 @@ public class Upgrade218to22 implements DbUpgrade { Long accountId = event.getAccountId(); // Get snapshot info (there was a bug in 2.1.x - accountId is 0, and data_center info is not present in events table - if (accountId.longValue() == 0L || zoneId == null) { + if (accountId.longValue() == 0L || zoneId.longValue() == 0L) { PreparedStatement pstmt = conn.prepareStatement("SELECT zone_id, account_id from usage_event where resource_id=? and type like '%SNAPSHOT%'"); pstmt.setLong(1, snapId); s_logger.debug("query is " + pstmt);