Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E938F200CBB for ; Mon, 19 Jun 2017 11:11:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E856B160BE1; Mon, 19 Jun 2017 09:11:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3BA90160BF1 for ; Mon, 19 Jun 2017 11:11:06 +0200 (CEST) Received: (qmail 18808 invoked by uid 500); 19 Jun 2017 09:11:05 -0000 Mailing-List: contact issues-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ambari.apache.org Delivered-To: mailing list issues@ambari.apache.org Received: (qmail 18797 invoked by uid 99); 19 Jun 2017 09:11:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Jun 2017 09:11:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D1D0B1822E2 for ; Mon, 19 Jun 2017 09:11:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 3TEwJwCFWgzA for ; Mon, 19 Jun 2017 09:11:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 4E7515FB43 for ; Mon, 19 Jun 2017 09:11:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6B66DE0A32 for ; Mon, 19 Jun 2017 09:11:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 79A562400F for ; Mon, 19 Jun 2017 09:11:00 +0000 (UTC) Date: Mon, 19 Jun 2017 09:11:00 +0000 (UTC) From: "Dmytro Sen (JIRA)" To: issues@ambari.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AMBARI-21248) Exception needs to be handled properly for mail alert MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 19 Jun 2017 09:11:07 -0000 [ https://issues.apache.org/jira/browse/AMBARI-21248?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:all-tabpanel ] Dmytro Sen updated AMBARI-21248: -------------------------------- Attachment: AMBARI-21248_4.patch > Exception needs to be handled properly for mail alert > ----------------------------------------------------- > > Key: AMBARI-21248 > URL: https://issues.apache.org/jira/browse/AMBARI-21248 > Project: Ambari > Issue Type: Bug > Components: ambari-server > Affects Versions: 2.4.2 > Reporter: Richard Zang > Assignee: Dmytro Sen > Priority: Critical > Fix For: 2.5.2 > > Attachments: AMBARI-21248_4.patch > > > In org.apache.ambari.server.state.services.AlertNoticeDispatchService, we= have below code snippet: > {code} > ...=20 > protected void runOneIteration() throws Exception {=20 > =E2=80=A6=20 > String targetType =3D target.getNotificationType();=20 > NotificationDispatcher dispatcher =3D m_dispatchFactory.getDispatcher(tar= getType);=20 > =E2=80=A6=20 > if (dispatcher.isDigestSupported()) {=20 > ... > {code} > If the database has a change to AlertTargetEntity's targetType column (un= likely but let's assume it happened), then dispatcher can be null and the s= ubsequent if clause will throw an exception. In https://github.com/google/g= uava/blob/master/guava/src/com/google/common/util/concurrent/AbstractSchedu= ledService.java, we see that the exception may happen silently since shutDo= wn() and notifyFailed() does not log anything.=20 > ...=20 > {code} > class Task implements Runnable { > @Override > public void run() { > lock.lock(); > try { > if (runningTask.isCancelled()) { // task may have been cancel= led while blocked on the lock. return; } > AbstractScheduledService.this.runOneIteration(); > } catch (Throwable t) { > try { > shutDown(); > } catch (Exception ignored) { > logger.log(Level.WARNING, "Error while attempting to = shut down the service after failure.", ignored); > } > notifyFailed(t); > runningTask.cancel(false); // prevent future invocations.= =20 > } finally { > lock.unlock(); > } > } > } > } > {code} > So, runOneIteration will shutdown the scheduler if it hits an uncaught ex= ception. We should wrap a try/catch. -- This message was sent by Atlassian JIRA (v6.4.14#64029)