diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java index 1de2b65aed1..82903104f90 100644 --- a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java +++ b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java @@ -276,17 +276,18 @@ public class ResourceCountDaoImpl extends GenericDaoBase } private long executeSqlCountComputingResourcesForAccount(long accountId, String sqlCountComputingResourcesAllocatedToAccount) { - try (TransactionLegacy tx = TransactionLegacy.currentTxn()) { + TransactionLegacy tx = TransactionLegacy.currentTxn(); + try { PreparedStatement pstmt = tx.prepareAutoCloseStatement(sqlCountComputingResourcesAllocatedToAccount); pstmt.setLong(1, accountId); ResultSet rs = pstmt.executeQuery(); if (!rs.next()) { - throw new CloudRuntimeException(String.format("An unexpected case happened while counting allocated computing resources for account: " + accountId)); + return 0L; } return rs.getLong("total"); } catch (SQLException e) { throw new CloudRuntimeException(e); } } -} \ No newline at end of file +}