You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/11/16 14:55:52 UTC
svn commit: r1815465 - in /tomcat/trunk:
java/javax/security/auth/message/config/AuthConfigFactory.java
webapps/docs/changelog.xml
Author: markt
Date: Thu Nov 16 14:55:51 2017
New Revision: 1815465
URL: http://svn.apache.org/viewvc?rev=1815465&view=rev
Log:
Improve concurrency by reducing the scope of the synchronisation for javax.security.auth.message.config.AuthConfigFactory in the JASPIC API implementation.
Based on a patch by Pavan Kumar.
Modified:
tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java?rev=1815465&r1=1815464&r2=1815465&view=diff
==============================================================================
--- tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java (original)
+++ tomcat/trunk/java/javax/security/auth/message/config/AuthConfigFactory.java Thu Nov 16 14:55:51 2017
@@ -48,40 +48,44 @@ public abstract class AuthConfigFactory
private static final String DEFAULT_JASPI_AUTHCONFIGFACTORYIMPL =
"org.apache.catalina.authenticator.jaspic.AuthConfigFactoryImpl";
- private static AuthConfigFactory factory;
+ private static volatile AuthConfigFactory factory;
public AuthConfigFactory() {
}
- public static synchronized AuthConfigFactory getFactory() {
+ public static AuthConfigFactory getFactory() {
checkPermission(getFactorySecurityPermission);
if (factory != null) {
return factory;
}
- final String className = getFactoryClassName();
- try {
- factory = AccessController.doPrivileged(
- new PrivilegedExceptionAction<AuthConfigFactory>() {
- @Override
- public AuthConfigFactory run() throws ReflectiveOperationException,
- IllegalArgumentException, SecurityException {
- // Load this class with the same class loader as used for
- // this class. Note that the Thread context class loader
- // should not be used since that would trigger a memory leak
- // in container environments.
- Class<?> clazz = Class.forName(className);
- return (AuthConfigFactory) clazz.getConstructor().newInstance();
+ synchronized (AuthConfigFactory.class) {
+ if (factory == null) {
+ final String className = getFactoryClassName();
+ try {
+ factory = AccessController.doPrivileged(
+ new PrivilegedExceptionAction<AuthConfigFactory>() {
+ @Override
+ public AuthConfigFactory run() throws ReflectiveOperationException,
+ IllegalArgumentException, SecurityException {
+ // Load this class with the same class loader as used for
+ // this class. Note that the Thread context class loader
+ // should not be used since that would trigger a memory leak
+ // in container environments.
+ Class<?> clazz = Class.forName(className);
+ return (AuthConfigFactory) clazz.getConstructor().newInstance();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ Exception inner = e.getException();
+ if (inner instanceof InstantiationException) {
+ throw (SecurityException) new SecurityException("AuthConfigFactory error:" +
+ inner.getCause().getMessage()).initCause(inner.getCause());
+ } else {
+ throw (SecurityException) new SecurityException(
+ "AuthConfigFactory error: " + inner).initCause(inner);
+ }
}
- });
- } catch (PrivilegedActionException e) {
- Exception inner = e.getException();
- if (inner instanceof InstantiationException) {
- throw (SecurityException) new SecurityException("AuthConfigFactory error:" +
- inner.getCause().getMessage()).initCause(inner.getCause());
- } else {
- throw (SecurityException) new SecurityException(
- "AuthConfigFactory error: " + inner).initCause(inner);
}
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1815465&r1=1815464&r2=1815465&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Nov 16 14:55:51 2017
@@ -73,6 +73,11 @@
parent and children fields are correctly updated to avoid a possible
<code>StackOverflowError</code>. (markt)
</fix>
+ <fix>
+ Improve concurrency by reducing the scope of the synchronisation for
+ <code>javax.security.auth.message.config.AuthConfigFactory</code> in the
+ JASPIC API implementation. Based on a patch by Pavan Kumar. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org