Repository: atlas
Updated Branches:
  refs/heads/master 243a43218 -> e272a28e8


ATLAS-2958: updated hooks to log exceptions on all notification failures

Signed-off-by: Madhan Neethiraj <mad...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/e272a28e
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/e272a28e
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/e272a28e

Branch: refs/heads/master
Commit: e272a28e861ee3926266e018b388ac6798dcd306
Parents: 243a432
Author: Maxim Neaga <maxneaga>
Authored: Thu Nov 8 14:09:45 2018 -0800
Committer: Madhan Neethiraj <mad...@apache.org>
Committed: Thu Nov 8 14:18:58 2018 -0800

----------------------------------------------------------------------
 .../main/java/org/apache/atlas/hook/AtlasHook.java | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/e272a28e/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java 
b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
index 31874af..0030276 100644
--- a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
+++ b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
@@ -172,9 +172,8 @@ public abstract class AtlasHook {
             return;
         }
 
-        final int    maxAttempts         = maxRetries < 1 ? 1 : maxRetries;
-        final String message             = messages.toString();
-        Exception    notificationFailure = null;
+        final int maxAttempts         = maxRetries < 1 ? 1 : maxRetries;
+        Exception notificationFailure = null;
 
         for (int numAttempt = 1; numAttempt <= maxAttempts; numAttempt++) {
             if (numAttempt > 1) { // retry attempt
@@ -214,14 +213,16 @@ public abstract class AtlasHook {
             }
         }
 
-        if (shouldLogFailedMessages && notificationFailure instanceof 
NotificationException) {
-            final List<String> failedMessages = ((NotificationException) 
notificationFailure).getFailedMessages();
+        if (notificationFailure != null) {
+            if (shouldLogFailedMessages && notificationFailure instanceof 
NotificationException) {
+                final List<String> failedMessages = ((NotificationException) 
notificationFailure).getFailedMessages();
 
-            for (String msg : failedMessages) {
-                logger.log(msg);
+                for (String msg : failedMessages) {
+                    logger.log(msg);
+                }
             }
 
-            LOG.error("Giving up after {} failed attempts to send notification 
to Atlas: {}", maxAttempts, message, notificationFailure);
+            LOG.error("Giving up after {} failed attempts to send notification 
to Atlas: {}", maxAttempts, messages.toString(), notificationFailure);
         }
     }
 

Reply via email to