Skip to content

Commit 1bb64e5

Browse files
author
Daan Hoogland
committed
server: Fix exception while update domain resource count (#3204)
reimplement 3303 on moved file in 4.12
1 parent 9488c6d commit 1bb64e5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

engine/schema/src/main/java/com/cloud/configuration/dao/ResourceCountDaoImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,18 @@ public long countMemoryAllocatedToAccount(long accountId) {
266266
}
267267

268268
private long executeSqlCountComputingResourcesForAccount(long accountId, String sqlCountComputingResourcesAllocatedToAccount) {
269-
try (TransactionLegacy tx = TransactionLegacy.currentTxn()) {
269+
TransactionLegacy tx = TransactionLegacy.currentTxn()
270+
try {
270271
PreparedStatement pstmt = tx.prepareAutoCloseStatement(sqlCountComputingResourcesAllocatedToAccount);
271272
pstmt.setLong(1, accountId);
272273

273274
ResultSet rs = pstmt.executeQuery();
274275
if (!rs.next()) {
275-
throw new CloudRuntimeException(String.format("An unexpected case happened while counting allocated computing resources for account: " + accountId));
276+
return 0L;
276277
}
277278
return rs.getLong("total");
278279
} catch (SQLException e) {
279280
throw new CloudRuntimeException(e);
280281
}
281282
}
282-
283-
}
283+
}

0 commit comments

Comments
 (0)