Actually use the BlockingQueueFactory plugin in AsyncAppender Whoopsies.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c2d75fa1 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c2d75fa1 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c2d75fa1 Branch: refs/heads/master Commit: c2d75fa1931a0118430f7ec3eecb0c3c46a9be6e Parents: 65ec9bc Author: Matt Sicker <boa...@gmail.com> Authored: Fri Jun 17 18:53:59 2016 -0500 Committer: Matt Sicker <boa...@gmail.com> Committed: Fri Jun 17 18:53:59 2016 -0500 ---------------------------------------------------------------------- .../log4j/core/appender/AsyncAppender.java | 3 +- .../core/async/BlockingQueueFactoryUtil.java | 46 -------------------- 2 files changed, 1 insertion(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c2d75fa1/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java index dee5e50..f7aa381 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java @@ -30,7 +30,6 @@ import org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory; import org.apache.logging.log4j.core.async.AsyncQueueFullPolicy; import org.apache.logging.log4j.core.async.AsyncQueueFullPolicyFactory; import org.apache.logging.log4j.core.async.BlockingQueueFactory; -import org.apache.logging.log4j.core.async.BlockingQueueFactoryUtil; import org.apache.logging.log4j.core.async.DiscardingAsyncQueueFullPolicy; import org.apache.logging.log4j.core.async.EventRoute; import org.apache.logging.log4j.core.config.AppenderControl; @@ -78,7 +77,7 @@ public final class AsyncAppender extends AbstractAppender { final boolean ignoreExceptions, final long shutdownTimeout, final Configuration config, final boolean includeLocation, final BlockingQueueFactory<LogEvent> blockingQueueFactory) { super(name, filter, null, ignoreExceptions); - this.queue = BlockingQueueFactoryUtil.<LogEvent>getBlockingQueueFactory().create(queueSize); + this.queue = blockingQueueFactory.create(queueSize); this.queueSize = queueSize; this.blocking = blocking; this.shutdownTimeout = shutdownTimeout; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c2d75fa1/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java deleted file mode 100644 index 4684b54..0000000 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.logging.log4j.core.async; - -import java.lang.reflect.InvocationTargetException; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.status.StatusLogger; -import org.apache.logging.log4j.util.LoaderUtil; - -/** - * Utility class for obtaining a {@link BlockingQueueFactory}. By default, {@link ArrayBlockingQueueFactory} is used, - * but this can be overridden by the system property {@code log4j.BlockingQueueFactory}. - * - * @since 2.7 - */ -public final class BlockingQueueFactoryUtil { - - private static final Logger LOGGER = StatusLogger.getLogger(); - - /** - * Returns a new BlockingQueueFactory. - * - * @return a BlockingQueueFactory instance - */ - public static <E> BlockingQueueFactory<E> getBlockingQueueFactory() { - BlockingQueueFactory<E> factory = null; - try { - factory = newBlockingQueueFactory(); - } catch (final ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { - LOGGER.error("Specified log4j.BlockingQueueFactory could not be instantiated.", e); - } - if (factory == null) { - factory = new ArrayBlockingQueueFactory<>(); - } - return factory; - } - - @SuppressWarnings("unchecked") - private static <E> BlockingQueueFactory<E> newBlockingQueueFactory() - throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, - InvocationTargetException { - return LoaderUtil.newCheckedInstanceOfProperty(BlockingQueueFactory.PROPERTY, BlockingQueueFactory.class); - } - - private BlockingQueueFactoryUtil() { - } -}