Author: rgoers
Date: Mon Jul 18 04:32:20 2011
New Revision: 1147737

URL: http://svn.apache.org/viewvc?rev=1147737&view=rev
Log:
WeakHashMaps don't need to be wrapped in a synchronized map since they are 
called from a single method while synchronized. Pass correct FQCN when locating 
context via SecurityManager.

Modified:
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/changes/changes.xml
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
    
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java?rev=1147737&r1=1147736&r2=1147737&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j12-api/src/main/java/org/apache/log4j/Category.java
 Mon Jul 18 04:32:20 2011
@@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentMa
  */
 public class Category {
     private static final Map<LoggerContext, ConcurrentMap<String, Logger>> 
contextMap =
-        Collections.synchronizedMap(new WeakHashMap<LoggerContext, 
ConcurrentMap<String, Logger>>());
+        new WeakHashMap<LoggerContext, ConcurrentMap<String, Logger>>();
 
     private final org.apache.logging.log4j.core.Logger logger;
 

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/changes/changes.xml?rev=1147737&r1=1147736&r2=1147737&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/changes/changes.xml
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/changes/changes.xml
 Mon Jul 18 04:32:20 2011
@@ -1 +1 @@
-<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

-->
<document>
  <properties>
    <title>Component</title>
  </properties>
  <body>
    <release version="0.1" date="2099-01-01" description="First release">
      <action dev="carnold" issue="42094" type="add">
        Initial release of Enhanced Pattern Layout backported from log4j 1.3.
      </action>
    </release>
  </body>
</document>
\ No newline at end of file
+<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

-->
<document>
  <properties>
    <title>Component</title>
  </properties>
  <body>
    <release version="2.0" date="@TBD@" description="First release">
      <action dev="rgoers" type="add">
        Initial release Log4j 2.0.
      </action>
    </release>
  </body>
</document>
\ No newline at end of file

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java?rev=1147737&r1=1147736&r2=1147737&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/selector/ClassLoaderContextSelector.java
 Mon Jul 18 04:32:20 2011
@@ -99,7 +99,7 @@ public class ClassLoaderContextSelector 
             }
 
             if (securityManager != null) {
-                Class clazz = securityManager.getCaller();
+                Class clazz = securityManager.getCaller(fqcn);
                 return locateContext(clazz.getClassLoader(), null);
             }
 
@@ -210,11 +210,11 @@ public class ClassLoaderContextSelector 
 
     private static class PrivateSecurityManager extends SecurityManager {
 
-        public Class getCaller() {
+        public Class getCaller(String fqcn) {
             Class[] classes = getClassContext();
             boolean next = false;
             for (Class clazz : classes) {
-                if (clazz.getName().equals(LogManager.class.getName())) {
+                if (clazz.getName().equals(fqcn)) {
                     next = true;
                     continue;
                 }

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java?rev=1147737&r1=1147736&r2=1147737&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-jcl/src/main/java/org/apache/logging/log4j/jcl/LogFactoryImpl.java
 Mon Jul 18 04:32:20 2011
@@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentMa
 public class LogFactoryImpl extends LogFactory {
 
     private final Map<LoggerContext, ConcurrentMap<String, Log>> contextMap =
-        Collections.synchronizedMap(new WeakHashMap<LoggerContext, 
ConcurrentMap<String, Log>>());
+        new WeakHashMap<LoggerContext, ConcurrentMap<String, Log>>();
 
     private ConcurrentMap<String, Object> attributes = new 
ConcurrentHashMap<String, Object>();
 

Modified: 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java?rev=1147737&r1=1147736&r2=1147737&view=diff
==============================================================================
--- 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
 (original)
+++ 
logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
 Mon Jul 18 04:32:20 2011
@@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentMa
  */
 public class Log4JLoggerFactory implements ILoggerFactory {
     private final Map<LoggerContext, ConcurrentMap<String, Logger>> contextMap 
=
-        Collections.synchronizedMap(new WeakHashMap<LoggerContext, 
ConcurrentMap<String, Logger>>());
+        new WeakHashMap<LoggerContext, ConcurrentMap<String, Logger>>();
 
     private static final String FQCN = Log4JLoggerFactory.class.getName();
     private static final String PACKAGE = "org.slf4j";



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to