[logback-dev] svn commit: r2116 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic test/java/ch/qos/logback/classic

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Dec 30 12:48:17 CET 2008


Author: ceki
Date: Tue Dec 30 12:48:16 2008
New Revision: 2116

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java

Log:

- LoggerContext reset, registered turbo filters are first stopped before being 
  unregistered. This fixes LBCLASSIC-89.
    

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java	Tue Dec 30 12:48:16 2008
@@ -54,7 +54,8 @@
 
   // We want loggerCache to be synchronized so Hashtable is a good choice. In
   // practice, it performs a little faster than the map returned by
-  // Collections.synchronizedMap at the cost of a very slightly higher memory footprint.
+  // Collections.synchronizedMap at the cost of a very slightly higher memory
+  // footprint.
   private Hashtable<String, Logger> loggerCache;
 
   private LoggerContextRemoteView loggerContextRemoteView;
@@ -193,13 +194,12 @@
    */
   public void reset() {
     root.recursiveReset();
-    clearAllTurboFilters();
+    resetTurboFilterList();
     fireOnReset();
     resetListenersExceptResetResistant();
     resetStatusListeners();
   }
 
-  
   private void resetStatusListeners() {
     StatusManager sm = getStatusManager();
     for (StatusListener sl : sm.getCopyOfStatusListenerList()) {
@@ -215,7 +215,14 @@
     turboFilterList.add(newFilter);
   }
 
-  public void clearAllTurboFilters() {
+  /**
+   * First stop all registered turbo filters and then clear the registration
+   * list.
+   */
+  public void resetTurboFilterList() {
+    for (TurboFilter tf : turboFilterList) {
+      tf.stop();
+    }
     turboFilterList.clear();
   }
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java	Tue Dec 30 12:48:16 2008
@@ -9,11 +9,17 @@
  */
 package ch.qos.logback.classic;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.junit.Before;
 import org.junit.Test;
 
+import ch.qos.logback.classic.turbo.NOPTurboFilter;
 import ch.qos.logback.core.status.StatusManager;
 
 public class LoggerContextTest {
@@ -170,6 +176,16 @@
     assertEquals(Level.DEBUG, root.getLevel());    
     assertNull(a.getLevel());
     assertNull(ab.getLevel());
-
+  }
+  
+  // http://jira.qos.ch/browse/LBCLASSIC-89
+  @Test
+  public void turboFilterStopOnReset() {
+    NOPTurboFilter nopTF = new NOPTurboFilter();
+    nopTF.start();
+    lc.addTurboFilter(nopTF);
+    assertTrue(nopTF.isStarted());
+    lc.reset();
+    assertFalse(nopTF.isStarted());
   }
 }
\ No newline at end of file


More information about the logback-dev mailing list