GabrielBrascher commented on a change in pull request #3204: server: Fix 
exception while update domain resource count
URL: https://github.com/apache/cloudstack/pull/3204#discussion_r277967554
 
 

 ##########
 File path: 
engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
 ##########
 @@ -276,17 +276,18 @@ public long countMemoryAllocatedToAccount(long 
accountId) {
     }
 
     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);
 
 Review comment:
   What about adding a message similar to the "An unexpected case happened 
while counting allocated..." to the exception stack?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to