Repository: logging-log4j2
Updated Branches:
  refs/heads/master 19969af09 -> cfc5897c0


LOG4J2-1422 since we're explicity installing the policy instance, store it in a 
field and make the counter non-static


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/cfc5897c
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/cfc5897c
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/cfc5897c

Branch: refs/heads/master
Commit: cfc5897c096be7f58ac991c000d91754f673edb6
Parents: 19969af
Author: rpopma <[email protected]>
Authored: Sat Jun 11 14:36:20 2016 +0900
Committer: rpopma <[email protected]>
Committed: Sat Jun 11 14:36:20 2016 +0900

----------------------------------------------------------------------
 .../appender/AsyncAppenderQueueFullPolicyTest.java | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cfc5897c/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
index f288f15..a5adf83 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
@@ -27,7 +27,6 @@ import org.apache.logging.log4j.core.async.EventRoute;
 import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.test.appender.BlockingAppender;
 import org.junit.After;
-import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -52,6 +51,7 @@ public class AsyncAppenderQueueFullPolicyTest {
 
     private BlockingAppender blockingAppender;
     private AsyncAppender asyncAppender;
+    private CountingAsyncQueueFullPolicy policy;
 
     @Before
     public void before() throws Exception {
@@ -60,14 +60,15 @@ public class AsyncAppenderQueueFullPolicyTest {
 
         Field field = 
AsyncAppender.class.getDeclaredField("asyncQueueFullPolicy");
         field.setAccessible(true);
-        field.set(asyncAppender, new CountingAsyncQueueFullPolicy());
-        CountingAsyncQueueFullPolicy.queueFull.set(0L);
+        policy = new CountingAsyncQueueFullPolicy();
+        field.set(asyncAppender, policy);
+        policy.queueFull.set(0L);
     }
 
     @After
     public void after() {
         blockingAppender.running = false;
-        CountingAsyncQueueFullPolicy.queueFull.set(0L);
+        policy.queueFull.set(0L);
     }
 
     @Test
@@ -80,11 +81,11 @@ public class AsyncAppenderQueueFullPolicyTest {
         logger.info("event 3");
         logger.info("event 4 - now the queue is full");
         assertEquals("queue remaining capacity", 0, 
asyncAppender.getQueueRemainingCapacity());
-        assertEquals("EventRouter invocations", 0, 
CountingAsyncQueueFullPolicy.queueFull.get());
+        assertEquals("EventRouter invocations", 0, policy.queueFull.get());
 
         final Thread release = new Thread("AsyncAppenderReleaser") {
             public void run() {
-                while (CountingAsyncQueueFullPolicy.queueFull.get() == 0) {
+                while (policy.queueFull.get() == 0) {
                     try {
                         Thread.sleep(10L);
                     } catch (final InterruptedException ignored) {
@@ -97,11 +98,11 @@ public class AsyncAppenderQueueFullPolicyTest {
         release.setDaemon(true);
         release.start();
         logger.fatal("this blocks until queue space available");
-        assertEquals(1, CountingAsyncQueueFullPolicy.queueFull.get());
+        assertEquals(1, policy.queueFull.get());
     }
 
     public static class CountingAsyncQueueFullPolicy extends 
DefaultAsyncQueueFullPolicy {
-        static AtomicLong queueFull = new AtomicLong();
+        AtomicLong queueFull = new AtomicLong();
         @Override
         public EventRoute getRoute(final long backgroundThreadId, final Level 
level) {
             queueFull.incrementAndGet();

Reply via email to