logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1587425 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
Date Tue, 15 Apr 2014 05:26:59 GMT
Author: mattsicker
Date: Tue Apr 15 05:26:59 2014
New Revision: 1587425

URL: http://svn.apache.org/r1587425
Log:
Use Loader.newCheckedInstanceOf.

  - Also noted busy wait usage (static code analysis complains; could use some justification?)

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java?rev=1587425&r1=1587424&r2=1587425&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
Tue Apr 15 05:26:59 2014
@@ -28,6 +28,7 @@ import org.apache.logging.log4j.core.Log
 import org.apache.logging.log4j.core.config.Property;
 import org.apache.logging.log4j.core.helpers.Clock;
 import org.apache.logging.log4j.core.helpers.ClockFactory;
+import org.apache.logging.log4j.core.helpers.Loader;
 import org.apache.logging.log4j.core.impl.Log4jLogEvent;
 import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
 import org.apache.logging.log4j.message.Message;
@@ -189,10 +190,8 @@ public class AsyncLogger extends Logger 
             return null;
         }
         try {
-            @SuppressWarnings("unchecked")
-            final Class<? extends ExceptionHandler> klass = (Class<? extends ExceptionHandler>)
Class.forName(cls);
-            final ExceptionHandler result = klass.newInstance();
-            LOGGER.debug("AsyncLogger.ExceptionHandler=" + result);
+            final ExceptionHandler result = Loader.newCheckedInstanceOf(cls, ExceptionHandler.class);
+            LOGGER.debug("AsyncLogger.ExceptionHandler={}", result);
             return result;
         } catch (final Exception ignored) {
             LOGGER.debug("AsyncLogger.ExceptionHandler not set: error creating " + cls +
": ", ignored);
@@ -305,6 +304,7 @@ public class AsyncLogger extends Logger 
             }
             try {
                 // give ringbuffer some time to drain...
+                // TODO: is there a better way to do this than busy-waiting?
                 Thread.sleep(HALF_A_SECOND);
             } catch (final InterruptedException e) {
                 // ignored



Mime
View raw message