Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 49864 invoked from network); 27 Jan 2011 17:13:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Jan 2011 17:13:04 -0000 Received: (qmail 25701 invoked by uid 500); 27 Jan 2011 17:13:04 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 25627 invoked by uid 500); 27 Jan 2011 17:13:02 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 25620 invoked by uid 99); 27 Jan 2011 17:13:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jan 2011 17:13:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jan 2011 17:13:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BE9142388ABA; Thu, 27 Jan 2011 17:12:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1064204 - /activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala Date: Thu, 27 Jan 2011 17:12:39 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110127171239.BE9142388ABA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Thu Jan 27 17:12:39 2011 New Revision: 1064204 URL: http://svn.apache.org/viewvc?rev=1064204&view=rev Log: NPE protection. Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala?rev=1064204&r1=1064203&r2=1064204&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala (original) +++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala Thu Jan 27 17:12:39 2011 @@ -39,17 +39,21 @@ trait Log { val log = LoggerFactory.getLogger(getClass.getName.stripSuffix("$")) private def with_throwable(e:Throwable)(func: =>Unit) = { - val stack_ref = if( log.isDebugEnabled ) { - val id = next_exception_id - MDC.put("stack reference", id.toString); - Some(id) + if( e!=null ) { + val stack_ref = if( log.isDebugEnabled ) { + val id = next_exception_id + MDC.put("stack reference", id.toString); + Some(id) + } else { + None + } + func + stack_ref.foreach { id=> + log.debug("stack trace: "+id, e) + MDC.remove("stack reference") + } } else { - None - } - func - stack_ref.foreach { id=> - log.debug("stack trace: "+id, e) - MDC.remove("stack reference") + func } }