Skip to content

Commit b60daf7

Browse files
ustcweizhouDaanHoogland
authored andcommitted
server: Fix exception while update domain resource count (#3204)
1 parent 96611fc commit b60daf7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,18 @@ public long countMemoryAllocatedToAccount(long accountId) {
276276
}
277277

278278
private long executeSqlCountComputingResourcesForAccount(long accountId, String sqlCountComputingResourcesAllocatedToAccount) {
279-
try (TransactionLegacy tx = TransactionLegacy.currentTxn()) {
279+
TransactionLegacy tx = TransactionLegacy.currentTxn();
280+
try {
280281
PreparedStatement pstmt = tx.prepareAutoCloseStatement(sqlCountComputingResourcesAllocatedToAccount);
281282
pstmt.setLong(1, accountId);
282283

283284
ResultSet rs = pstmt.executeQuery();
284285
if (!rs.next()) {
285-
throw new CloudRuntimeException(String.format("An unexpected case happened while counting allocated computing resources for account: " + accountId));
286+
return 0L;
286287
}
287288
return rs.getLong("total");
288289
} catch (SQLException e) {
289290
throw new CloudRuntimeException(e);
290291
}
291292
}
292-
}
293+
}

0 commit comments

Comments
 (0)