You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/04/12 18:33:56 UTC

[16/17] logging-log4j2 git commit: LOG4J2-1343 increase iterations to increase probability of finding occasional problems; make errors in background thread (if any) accessible to test runner thread

LOG4J2-1343 increase iterations to increase probability of finding occasional problems; make errors in background thread (if any) accessible to test runner thread


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

Branch: refs/heads/master
Commit: 9974a1f51e4d37b4080ccef3e6cf3e42d9c232cf
Parents: c70775c
Author: rpopma <rp...@apache.org>
Authored: Tue Apr 12 22:26:26 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Tue Apr 12 22:26:26 2016 +0900

----------------------------------------------------------------------
 .../log4j/core/appender/FileAppenderTest.java   | 21 +++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9974a1f5/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
index df0b2b2..eea70ff 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java
@@ -105,26 +105,34 @@ public class FileAppenderTest {
     @Test
     public void testMultipleAppenders() throws Exception {
         final ExecutorService pool = Executors.newFixedThreadPool(THREADS);
-        final int count = 10;
-        final Runnable runnable = new FileWriterRunnable(false, count);
+        final Exception[] error = new Exception[1];
+        final int count = 100;
+        final Runnable runnable = new FileWriterRunnable(false, count, error);
         for (int i = 0; i < THREADS; ++i) {
             pool.execute(runnable);
         }
         pool.shutdown();
         pool.awaitTermination(10, TimeUnit.SECONDS);
+        if (error[0] != null) {
+            throw error[0];
+        }
         verifyFile(THREADS * count);
     }
 
     @Test
     public void testMultipleLockedAppenders() throws Exception {
         final ExecutorService pool = Executors.newFixedThreadPool(THREADS);
-        final int count = 10;
-        final Runnable runnable = new FileWriterRunnable(true, count);
+        final Exception[] error = new Exception[1];
+        final int count = 100;
+        final Runnable runnable = new FileWriterRunnable(true, count, error);
         for (int i = 0; i < THREADS; ++i) {
             pool.execute(runnable);
         }
         pool.shutdown();
         pool.awaitTermination(10, TimeUnit.SECONDS);
+        if (error[0] != null) {
+            throw error[0];
+        }
         verifyFile(THREADS * count);
     }
 
@@ -207,10 +215,12 @@ public class FileAppenderTest {
     public class FileWriterRunnable implements Runnable {
         private final boolean lock;
         private final int count;
+        private final Exception[] error;
 
-        public FileWriterRunnable(final boolean lock, final int count) {
+        public FileWriterRunnable(final boolean lock, final int count, final Exception[] error) {
             this.lock = lock;
             this.count = count;
+            this.error = error;
         }
 
         @Override
@@ -221,6 +231,7 @@ public class FileAppenderTest {
                 writer(lock, count, thread.getName());
 
             } catch (final Exception ex) {
+                error[0] = ex;
                 throw new RuntimeException(ex);
             }
         }