Repository: atlas Updated Branches: refs/heads/branch-1.0 b71f66436 -> 9e13df6e3
ATLAS-2958: updated hooks to log exceptions on all notification failures Signed-off-by: Madhan Neethiraj <[email protected]> (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/9e13df6e Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/9e13df6e Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/9e13df6e Branch: refs/heads/branch-1.0 Commit: 9e13df6e33939a55aaecf52db40fd54d3fecaf29 Parents: b71f664 Author: Maxim Neaga <maxneaga> Authored: Thu Nov 8 14:09:45 2018 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Thu Nov 8 14:20:39 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/9e13df6e/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); } }
