mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
6845161: Bottleneck in Configuration.getConfiguration synchronized call
Reduce scope of synchronized block Reviewed-by: weijun
This commit is contained in:
parent
8a52d1a9d5
commit
46c0719042
1 changed files with 43 additions and 41 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -234,56 +234,58 @@ public abstract class Configuration {
|
||||||
*
|
*
|
||||||
* @see #setConfiguration
|
* @see #setConfiguration
|
||||||
*/
|
*/
|
||||||
public static synchronized Configuration getConfiguration() {
|
public static Configuration getConfiguration() {
|
||||||
|
|
||||||
SecurityManager sm = System.getSecurityManager();
|
SecurityManager sm = System.getSecurityManager();
|
||||||
if (sm != null)
|
if (sm != null)
|
||||||
sm.checkPermission(new AuthPermission("getLoginConfiguration"));
|
sm.checkPermission(new AuthPermission("getLoginConfiguration"));
|
||||||
|
|
||||||
if (configuration == null) {
|
synchronized (Configuration.class) {
|
||||||
String config_class = null;
|
if (configuration == null) {
|
||||||
config_class = AccessController.doPrivileged
|
String config_class = null;
|
||||||
(new PrivilegedAction<String>() {
|
config_class = AccessController.doPrivileged
|
||||||
public String run() {
|
(new PrivilegedAction<String>() {
|
||||||
return java.security.Security.getProperty
|
public String run() {
|
||||||
("login.configuration.provider");
|
return java.security.Security.getProperty
|
||||||
}
|
("login.configuration.provider");
|
||||||
});
|
|
||||||
if (config_class == null) {
|
|
||||||
config_class = "com.sun.security.auth.login.ConfigFile";
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final String finalClass = config_class;
|
|
||||||
configuration = AccessController.doPrivileged
|
|
||||||
(new PrivilegedExceptionAction<Configuration>() {
|
|
||||||
public Configuration run() throws ClassNotFoundException,
|
|
||||||
InstantiationException,
|
|
||||||
IllegalAccessException {
|
|
||||||
return (Configuration)Class.forName
|
|
||||||
(finalClass,
|
|
||||||
true,
|
|
||||||
contextClassLoader).newInstance();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (PrivilegedActionException e) {
|
if (config_class == null) {
|
||||||
Exception ee = e.getException();
|
config_class = "com.sun.security.auth.login.ConfigFile";
|
||||||
if (ee instanceof InstantiationException) {
|
}
|
||||||
throw (SecurityException) new
|
|
||||||
SecurityException
|
try {
|
||||||
("Configuration error:" +
|
final String finalClass = config_class;
|
||||||
ee.getCause().getMessage() +
|
configuration = AccessController.doPrivileged
|
||||||
"\n").initCause(ee.getCause());
|
(new PrivilegedExceptionAction<Configuration>() {
|
||||||
} else {
|
public Configuration run() throws ClassNotFoundException,
|
||||||
throw (SecurityException) new
|
InstantiationException,
|
||||||
SecurityException
|
IllegalAccessException {
|
||||||
("Configuration error: " +
|
return (Configuration)Class.forName
|
||||||
ee.toString() +
|
(finalClass,
|
||||||
"\n").initCause(ee);
|
true,
|
||||||
|
contextClassLoader).newInstance();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (PrivilegedActionException e) {
|
||||||
|
Exception ee = e.getException();
|
||||||
|
if (ee instanceof InstantiationException) {
|
||||||
|
throw (SecurityException) new
|
||||||
|
SecurityException
|
||||||
|
("Configuration error:" +
|
||||||
|
ee.getCause().getMessage() +
|
||||||
|
"\n").initCause(ee.getCause());
|
||||||
|
} else {
|
||||||
|
throw (SecurityException) new
|
||||||
|
SecurityException
|
||||||
|
("Configuration error: " +
|
||||||
|
ee.toString() +
|
||||||
|
"\n").initCause(ee);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return configuration;
|
||||||
}
|
}
|
||||||
return configuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue