+ if (strategy != null) {
+ LOGGER.trace("[{}] property AsyncLogger.WaitStrategy={}",
contextName, strategy);
+ if ("Sleep".equals(strategy)) {
+ return new SleepingWaitStrategy();
+ } else if ("Yield".equals(strategy)) {
+ return new YieldingWaitStrategy();
+ } else if ("Block".equals(strategy)) {
+ return new BlockingWaitStrategy();
+ }
I think this kind of code would be cleaner with at least a String switch or
a switch based on an Enum. This should also be case-insensitive.
Gary
---------- Forwarded message ----------
From: Remko Popma (JIRA) <[email protected]>
Date: Thu, Oct 22, 2015 at 11:40 PM
Subject: [jira] [Commented] (LOG4J2-493) Problem with AsyncLogger when web
app is deployed/undeployed multiple times
To: [email protected]
[
https://issues.apache.org/jira/browse/LOG4J2-493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14970535#comment-14970535
]
Remko Popma commented on LOG4J2-493:
------------------------------------
Made further changes to handle the case where the log4j jars are in
$catalina.home/lib, but the log4j2.xml config file is in the WEB-INF/lib
folder of one of the web apps. In this scenario, the Disruptor should only
be started for web apps with a log4j2 config file.
The other web apps have a LoggerContext (because the
Log4jServletContextListener detects them), but use the DefaultConfiguration
(config not found). Starting a Disruptor for these contexts would be
wasteful.
I will mark this issue as resolved when I have a chance to commit these
changes.
> Problem with AsyncLogger when web app is deployed/undeployed multiple
times
>
---------------------------------------------------------------------------
>
> Key: LOG4J2-493
> URL: https://issues.apache.org/jira/browse/LOG4J2-493
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0-beta9, 2.0-rc1
> Environment: tomcat 7.0.42
> Reporter: Kireet Reddy
> Assignee: Remko Popma
> Labels: Async
> Fix For: 2.5
>
>
> |_This ticket tracks Async Logger issues in Tomcat when making all
loggers async with LoggerContextSelector system property. For Tomcat issues
with AsyncRoot/AsyncLogger in the configuration file, see LOG4J2-323._|
> When redeploying my application in tomcat multiple times, I get an
exception:
> {code}
> Exception in thread "Thread-29" java.lang.NullPointerException
> at
org.apache.logging.log4j.core.async.AsyncLogger.stop(AsyncLogger.java:249)
> at
org.apache.logging.log4j.core.async.AsyncLoggerContext.stop(AsyncLoggerContext.java:56)
> at
org.apache.logging.log4j.core.LoggerContext$ShutdownThread.run(LoggerContext.java:437)
> {code}
> This seems to be due to the fact that some initialization code happens in
the class initializer but is undone in the stop() method which is called
during webapp undeployment. This causes issues because in this case the
log4j jar is loaded by the shared classloader ($catalina.home/lib) rather
than the webapp classloader. This means the AsyncLogger class is not
re-created during webapp deployment.
> I am using this structure because I have many 3rd party libraries and
want to keep redeployments lightweight.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory