You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/01/27 18:12:39 UTC
svn commit: r1064204 -
/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
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
}
}