logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject svn commit: r386399 - /logging/log4j/trunk/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java
Date Thu, 16 Mar 2006 17:40:01 GMT
Author: carnold
Date: Thu Mar 16 09:39:58 2006
New Revision: 386399

URL: http://svn.apache.org/viewcvs?rev=386399&view=rev
Log:
Bug 30106: AsyncAppender can hang if appender logs

Modified:
    logging/log4j/trunk/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java

Modified: logging/log4j/trunk/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java?rev=386399&r1=386398&r2=386399&view=diff
==============================================================================
--- logging/log4j/trunk/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java (original)
+++ logging/log4j/trunk/tests/src/java/org/apache/log4j/AsyncAppenderTestCase.java Thu Mar
16 09:39:58 2006
@@ -446,6 +446,30 @@
         }
     }
 
+    /**
+     * Tests behavior when wrapped appender
+     *    makes log request on dispatch thread.
+     *
+     * See bug 30106
+     */
+    public void testLoggingInDispatcher() throws InterruptedException {
+        BlockableVectorAppender appender = new BlockableVectorAppender();
+        asyncAppender =
+          createAsyncAppender(appender, 2);
+        //
+        //   triggers several log requests on dispatch thread
+        //
+        root.fatal("Anybody up there...");
+        Thread.sleep(100);
+        asyncAppender.close();
+
+        Vector events = appender.getVector();
+        //
+        //  last message should start with "Discarded"
+        LoggingEvent event = (LoggingEvent) events.get(events.size() - 1);
+        assertEquals("Discarded", event.getMessage().toString().substring(0, 9));
+    }
+
 
   /**
    * Appender that throws a NullPointerException on calls to append.
@@ -552,6 +576,16 @@
       synchronized (monitor) {
         dispatcher = Thread.currentThread();
         super.append(event);
+          //
+          //   if fatal, echo messages for testLoggingInDispatcher
+          //
+          if (event.getLevel() == Level.FATAL) {
+              Logger logger = event.getLogger();
+              logger.error(event.getMessage().toString());
+              logger.warn(event.getMessage().toString());
+              logger.info(event.getMessage().toString());
+              logger.debug(event.getMessage().toString());
+          }
       }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message