mprokopchuk commented on code in PR #7670:
URL: https://github.com/apache/cloudstack/pull/7670#discussion_r1242569258


##########
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java:
##########
@@ -1156,8 +1156,24 @@ public ResourceCountCheckTask() {
         @Override
         protected void runInContext() {
             s_logger.info("Started resource counters recalculation periodic 
task.");
-            List<DomainVO> domains = 
_domainDao.findImmediateChildrenForParent(Domain.ROOT_DOMAIN);
-            List<AccountVO> accounts = 
_accountDao.findActiveAccountsForDomain(Domain.ROOT_DOMAIN);
+            List<DomainVO> domains;
+            List<AccountVO> accounts;
+            // try/catch task, otherwise it won't be rescheduled in case of 
exception
+            try {
+                domains = 
_domainDao.findImmediateChildrenForParent(Domain.ROOT_DOMAIN);
+            } catch (Exception e) {
+                s_logger.warn("Resource counters recalculation periodic task 
failed, unable to fetch immediate children for the domain " + 
Domain.ROOT_DOMAIN, e);
+                // initialize domains as empty list to do best effort 
recalculation
+                domains = new ArrayList<>();
+            }
+            // try/catch task, otherwise it won't be rescheduled in case of 
exception
+            try {
+                accounts = 
_accountDao.findActiveAccountsForDomain(Domain.ROOT_DOMAIN);
+            } catch (Exception e) {
+                s_logger.warn("Resource counters recalculation periodic task 
failed, unable to fetch active accounts for domain " + Domain.ROOT_DOMAIN, e);
+                // initialize accounts as empty list to do best effort 
recalculation
+                accounts = new ArrayList<>();
+            }

Review Comment:
   It is Shadowing in Java nested classes: 
https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html#shadowing



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to