You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/11/01 20:03:37 UTC

[GitHub] [cloudstack] joseflauzino opened a new pull request #5649: Handle NullPointerException when sending email alerts

joseflauzino opened a new pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649


   ### Description
   
   This PR adds more appropriate handling of NullPointerException when sending email alerts caused due to the recipient list being empty (or null). It also improves some log messages and adds unit test cases that address this type of handling.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   
   ### How Has This Been Tested?
   
   I ran all related unit tests and they all passed successfully.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741889484



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "subject" and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.

##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "account", "subject", and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.

##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing costs is irrelevant.

##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "subject" and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.

##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "account", "subject", and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.

##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing costs is irrelevant.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957242639


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1658


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] ravening commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
ravening commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741130770



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Not a big deal but `Unable to send quota alert email` might give different meaning like something wrong with email system or configuration but the actual reason is the empty list. Just mentioning that the list is empty should be good enough




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957125305






-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd merged pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
rhtyd merged pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649


   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] ravening commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
ravening commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741130770



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Not a big deal but `Unable to send quota alert email` might give different meaning like something wrong with email system or configuration but the actual reason is the empty list. Just mentioning that the list is empty should be good enough




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] shwstppr commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957094580


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742270648



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing cost is irrelevant.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957125305


   Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_multiplication_x: suse15. SL-JID 1656


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742270648



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing cost is irrelevant.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742227363



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       why remove the level check?
   ```suggestion
               if (logger.isDebugEnabled()) {
                   logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
               }
   ```

##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       why remove the level check?
   ```suggestion
               if (logger.isDebugEnabled()) {
                   logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
               }
   ```




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957125305






-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741889484



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "account", "subject", and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742227363



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       why remove the level check?
   ```suggestion
               if (logger.isDebugEnabled()) {
                   logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
               }
   ```




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741889484



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "subject" and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.

##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "account", "subject", and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.

##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing costs is irrelevant.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957198331


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] shwstppr commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957094580


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742270648



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing cost is irrelevant.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957200355


   @sureshanaparti a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-972771382


   I'll check it locally.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741889484



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Thanks for the review @ravening
   I changed the message to make it more evident that quota alert emails are not being sent just because the email list is empty. But I found it important to keep the "subject" and "content" information, because it makes it easier to decide if it's something crucial to deal with or not.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742270648



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       @DaanHoogland My intention is to reduce cyclomatic complexity, as this check is only executed because we did not update to Log4J yet. Also, for this situation, the computing costs is irrelevant.




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-972638675


   @rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-975327405


   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-974034129


   @joseflauzino a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] ravening commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
ravening commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r741130770



##########
File path: framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java
##########
@@ -325,14 +326,20 @@ public void sentSuccessfully(final QuotaAccountDao quotaAccountDao) {
         }
     };
 
-    protected void sendQuotaAlert(List<String> emails, String subject, String body) {
+    protected void sendQuotaAlert(String accountUuid, List<String> emails, String subject, String body) {
         SMTPMailProperties mailProperties = new SMTPMailProperties();
 
         mailProperties.setSender(new MailAddress(senderAddress));
         mailProperties.setSubject(subject);
         mailProperties.setContent(body);
         mailProperties.setContentType("text/html; charset=utf-8");
 
+        if (CollectionUtils.isEmpty(emails)) {
+            s_logger.warn(String.format("Unable to send quota alert email with subject [%s] and content [%s]. "

Review comment:
       Not a big deal but `Unable to send quota alert email` might give different meaning like something wrong with email system or configuration but the actual reason is the empty list. Just mentioning that the list is empty should be good enough




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957198331


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] shwstppr commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957094580


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-972735911


   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 1725


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-975326394


   @blueorangutan test


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] rhtyd commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-972638235


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-974081800


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1748


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] blueorangutan commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-975853117


   <b>Trillian test result (tid-2571)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 34632 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5649-t2571-kvm-centos7.zip
   Smoke tests completed. 91 look OK, 0 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] joseflauzino commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
joseflauzino commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-974032808


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] sureshanaparti commented on pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#issuecomment-957198331


   @blueorangutan package


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5649: Handle NullPointerException when sending email alerts

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #5649:
URL: https://github.com/apache/cloudstack/pull/5649#discussion_r742227363



##########
File path: server/src/main/java/com/cloud/alert/AlertManagerImpl.java
##########
@@ -706,14 +707,13 @@ public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long c
             newAlert.setName(alertType.getName());
             _alertDao.persist(newAlert);
         } else {
-            if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
-                }
+            logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");

Review comment:
       why remove the level check?
   ```suggestion
               if (logger.isDebugEnabled()) {
                   logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email");
               }
   ```




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org