Repository: logging-log4j2
Updated Branches:
  refs/heads/master 1c786f6af -> 5a14032f2


Make sure that IdlePurgePolicy can handle an appender which hang on shutdown


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

Branch: refs/heads/master
Commit: 5a14032f27642b4e6dc78ad32778ef7c8e015c7b
Parents: 1c786f6
Author: Mikael Ståldal <mikael.stal...@magine.com>
Authored: Wed Dec 2 10:42:21 2015 +0100
Committer: Mikael Ståldal <mikael.stal...@magine.com>
Committed: Wed Dec 2 10:42:21 2015 +0100

----------------------------------------------------------------------
 .../log4j/core/appender/HangingAppender.java    | 29 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/5a14032f/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
index a3ebbf0..3d456f2 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/HangingAppender.java
@@ -33,10 +33,14 @@ public class HangingAppender extends AbstractAppender {
     private static final long serialVersionUID = 1L;
 
     private final long delay;
+    private final long startupDelay;
+    private final long shutdownDelay;
 
-    public HangingAppender(final String name, final long delay) {
+    public HangingAppender(final String name, final long delay, final long 
startupDelay, final long shutdownDelay) {
         super(name, null, null);
         this.delay = delay;
+        this.startupDelay = startupDelay;
+        this.shutdownDelay = shutdownDelay;
     }
 
     @Override
@@ -54,9 +58,30 @@ public class HangingAppender extends AbstractAppender {
             @Required(message = "No name provided for HangingAppender")
             final String name,
             @PluginAttribute("delay") final long delay,
+            @PluginAttribute("startupDelay") final long startupDelay,
+            @PluginAttribute("shutdownDelay") final long shutdownDelay,
             @PluginElement("Layout") final Layout<? extends Serializable> 
layout,
             @PluginElement("Filter") final Filter filter) {
-        return new HangingAppender(name, delay);
+        return new HangingAppender(name, delay, startupDelay, shutdownDelay);
     }
 
+    @Override
+    public void start() {
+        try {
+            Thread.sleep(startupDelay);
+        } catch (InterruptedException ignore) {
+            // ignore
+        }
+        super.start();
+    }
+
+    @Override
+    public void stop() {
+        super.stop();
+        try {
+            Thread.sleep(shutdownDelay);
+        } catch (InterruptedException ignore) {
+            // ignore
+        }
+    }
 }

Reply via email to