Yair Zaslavsky has uploaded a new change for review.

Change subject: tools: Fixing npe at notification service log
......................................................................

tools: Fixing npe at notification service log

Both MAIL_FORM and MAIL_USER are not mandatory to send
a notification, but if a notification sending has failed
the log message uses the from object (which is set either by using
MAIL_FROM if exists at the configuration
, or by MAIL_USER if MAIL_FROM doesn't exist in
the configuration).
The log is fixed to handle possible NPEs

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=880597
Change-Id: If25ef37b0d9ff79737e7dfe8283322acb81c1dcb
signed-off-by: Yair Zaslavsky <yzasl...@redhat.com>
---
M 
backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
1 file changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/9726/1

diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
index 2e2649d..1def651 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/JavaMailSender.java
@@ -175,11 +175,19 @@
                 Transport.send(msg);
             }
         } catch (MessagingException mex) {
-            log.error(String.format("Failed to send message from [%s] to [%s] 
with subject [%s] due to error: [%s]",
-                    from.toString(),
-                    recipient,
-                    messageSubject,
-                    mex.getMessage()), mex);
+            
+            StringBuilder errorMsg = new StringBuilder("Failed to send message 
");
+            if (from != null) {
+                errorMsg.append(" from " + from.toString());
+            }
+            if (recipient != null) {
+                errorMsg.append(" to " + recipient);
+            }
+            if (messageSubject != null) {
+                errorMsg.append(" with subject " + messageSubject);
+            }
+            errorMsg.append(" due to to error: " + mex.getMessage());
+            log.error(errorMsg.toString(), mex);
             throw mex;
         }
     }


--
To view, visit http://gerrit.ovirt.org/9726
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If25ef37b0d9ff79737e7dfe8283322acb81c1dcb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <yzasl...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to