[slf4j-dev] svn commit: r1268 - in slf4j/trunk/slf4j-ext/src: main/java/org/slf4j test/java/org/slf4j

ceki at slf4j.org ceki at slf4j.org
Fri Jan 23 10:54:40 CET 2009


Author: ceki
Date: Fri Jan 23 10:54:40 2009
New Revision: 1268

Modified:
   slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/NDC.java
   slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/NDCTest.java

Log:
Minor refactoring

Modified: slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/NDC.java
==============================================================================
--- slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/NDC.java	(original)
+++ slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/NDC.java	Fri Jan 23 10:54:40 2009
@@ -42,17 +42,17 @@
   }
 
   public static void push(String val) {
-    int last = size();
-    MDC.put(PREFIX + last, val);
+    int next = size();
+    MDC.put(PREFIX + next, val);
   }
 
   public static String pop() {
-    int i = size();
-    if(i == 0) {
+    int next = size();
+    if(next == 0) {
       return "";
     }
-    i--;
-    String key = PREFIX+i;
+    int last = next-1; 
+    String key = PREFIX+last;
     String val = MDC.get(key);
     MDC.remove(key);
     return val;

Modified: slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/NDCTest.java
==============================================================================
--- slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/NDCTest.java	(original)
+++ slf4j/trunk/slf4j-ext/src/test/java/org/slf4j/NDCTest.java	Fri Jan 23 10:54:40 2009
@@ -36,6 +36,10 @@
     super.tearDown();
   }
   
+  public void testEmpty() {
+    assertEquals("", NDC.pop());
+  }
+  
   public void testSmoke() {
     NDC.push("a");
     String result = NDC.pop();



More information about the slf4j-dev mailing list