ambari-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Zang (JIRA)" <>
Subject [jira] [Created] (AMBARI-21248) Exception needs to be handled properly for mail alert
Date Wed, 14 Jun 2017 17:27:00 GMT
Richard Zang created AMBARI-21248:

             Summary: Exception needs to be handled properly for mail alert
                 Key: AMBARI-21248
             Project: Ambari
          Issue Type: Bug
          Components: ambari-server
    Affects Versions: 2.4.2
            Reporter: Richard Zang
            Assignee: Dmytro Sen
             Fix For: 2.5.2

In, we have below code
protected void runOneIteration() throws Exception { 
String targetType = target.getNotificationType(); 
NotificationDispatcher dispatcher = m_dispatchFactory.getDispatcher(targetType); 
if (dispatcher.isDigestSupported()) { 
If the database has a change to AlertTargetEntity's targetType column (unlikely but let's
assume it happened), then dispatcher can be null and the subsequent if clause will throw an
exception. In,
we see that the exception may happen silently since shutDown() and notifyFailed() does not
log anything. 
class Task implements Runnable {
    public void run() {
        try {
            if (runningTask.isCancelled()) { // task may have been cancelled while blocked
on the lock. return; }

            } catch (Throwable t) {
                try {
                } catch (Exception ignored) {
                    logger.log(Level.WARNING, "Error while attempting to shut down the service
after failure.", ignored);

                runningTask.cancel(false); // prevent future invocations. 
            } finally {

So, runOneIteration will shutdown the scheduler if it hits an uncaught exception. We should
wrap a try/catch.

This message was sent by Atlassian JIRA

View raw message