logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jed Wesley-Smith (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-169) ConfigurationFactory is not thread-safe
Date Thu, 21 Feb 2013 04:10:12 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jed Wesley-Smith updated LOG4J2-169:
------------------------------------

         Labels: thread-safety  (was: )
    Description: 
We randomly get the following:

java.util.ConcurrentModificationException
	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:377)
	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:361)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:266)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:134)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:30)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:165)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:174)
	at …

factories is defined as:

    private static List<ConfigurationFactory> factories = new ArrayList<ConfigurationFactory>();

The simple fix is to use a java.util.concurrent.CopyOnWriteArrayList:

    private static final List<ConfigurationFactory> factories = new CopyOnWriteArrayList<ConfigurationFactory>();

https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java

  was:
We randomly get the following:

{noformat}
java.util.ConcurrentModificationException
	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:377)
	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:361)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:266)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:134)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:30)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:165)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:174)
	at …
{noformat}

factories is defined as:

{code}
    private static List<ConfigurationFactory> factories = new ArrayList<ConfigurationFactory>();
{code}

The simple fix is to use a java.util.concurrent.CopyOnWriteArrayList:

{code}
    private static final List<ConfigurationFactory> factories = new CopyOnWriteArrayList<ConfigurationFactory>();
{code}

https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java

    
> ConfigurationFactory is not thread-safe
> ---------------------------------------
>
>                 Key: LOG4J2-169
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-169
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-beta4
>            Reporter: Jed Wesley-Smith
>              Labels: thread-safety
>
> We randomly get the following:
> java.util.ConcurrentModificationException
> 	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:377)
> 	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:361)
> 	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:266)
> 	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:134)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:30)
> 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:165)
> 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:174)
> 	at …
> factories is defined as:
>     private static List<ConfigurationFactory> factories = new ArrayList<ConfigurationFactory>();
> The simple fix is to use a java.util.concurrent.CopyOnWriteArrayList:
>     private static final List<ConfigurationFactory> factories = new CopyOnWriteArrayList<ConfigurationFactory>();
> https://svn.apache.org/repos/asf/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message