You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2016/02/24 06:35:28 UTC
[2/2] logging-log4j2 git commit: Use LoaderUtil.loadClass and remove
need for supress warnings.
Use LoaderUtil.loadClass and remove need for supress warnings.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f67fac87
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f67fac87
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f67fac87
Branch: refs/heads/master
Commit: f67fac870d7a07110c4318d498955ce6be57686c
Parents: 3ae452e
Author: Matt Sicker <bo...@gmail.com>
Authored: Tue Feb 23 23:35:32 2016 -0600
Committer: Matt Sicker <bo...@gmail.com>
Committed: Tue Feb 23 23:35:32 2016 -0600
----------------------------------------------------------------------
.../logging/log4j/core/async/AsyncEventRouterFactory.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f67fac87/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncEventRouterFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncEventRouterFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncEventRouterFactory.java
index f2ef388..a1b254f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncEventRouterFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncEventRouterFactory.java
@@ -16,13 +16,14 @@
*/
package org.apache.logging.log4j.core.async;
+import java.lang.reflect.Constructor;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
import org.apache.logging.log4j.util.PropertiesUtil;
-import java.lang.reflect.Constructor;
-
/**
* Creates {@link AsyncEventRouter} instances based on user-specified system properties. The {@code AsyncEventRouter}
* created by this factory is used in AsyncLogger, AsyncLoggerConfig and AsyncAppender
@@ -86,11 +87,10 @@ public class AsyncEventRouterFactory {
private static AsyncEventRouter createCustomRouter(final String router, final int queueSize) {
try {
- @SuppressWarnings("unchecked")
- final Class<AsyncEventRouter> cls = (Class<AsyncEventRouter>) Class.forName(router);
+ final Class<? extends AsyncEventRouter> cls = LoaderUtil.loadClass(router).asSubclass(AsyncEventRouter.class);
try {
// if the custom router has a constructor taking an int, pass it the queue size
- Constructor<AsyncEventRouter> constructor = cls.getDeclaredConstructor(new Class[]{int.class});
+ Constructor<? extends AsyncEventRouter> constructor = cls.getDeclaredConstructor(new Class[]{int.class});
LOGGER.debug("Creating custom AsyncEventRouter '{}({})'", router, queueSize);
return constructor.newInstance(new Object[]{queueSize});
} catch (final Exception e) {