activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
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 GMT
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
     }
   }
 



Mime
View raw message