Repository: atlas Updated Branches: refs/heads/branch-0.8 ae6cb093b -> 8d7e94db7
ATLAS-2958: updated hooks to log exceptions on all notification failures Signed-off-by: Madhan Neethiraj <mad...@apache.org> (cherry picked from commit e272a28e861ee3926266e018b388ac6798dcd306) Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/8d7e94db Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/8d7e94db Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/8d7e94db Branch: refs/heads/branch-0.8 Commit: 8d7e94db71f81d94e17736b961844052b0f62c4b Parents: ae6cb09 Author: Maxim Neaga <maxneaga> Authored: Thu Nov 8 14:09:45 2018 -0800 Committer: Madhan Neethiraj <mad...@apache.org> Committed: Thu Nov 8 14:21:14 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/8d7e94db/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 d4b0715..08e130b 100644 --- a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java +++ b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java @@ -187,9 +187,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 @@ -229,14 +228,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); } }