mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-23 05:10:57 +00:00
8028627: Unsynchronized code path from javax.crypto.Cipher to the WeakHashMap used by JceSecurity to store codebase mappings
Reviewed-by: mullan
This commit is contained in:
parent
3172613954
commit
4b44e25310
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -216,26 +216,28 @@ final class JceSecurity {
|
||||
new WeakHashMap<>();
|
||||
|
||||
/*
|
||||
* Retuns the CodeBase for the given class.
|
||||
* Returns the CodeBase for the given class.
|
||||
*/
|
||||
static URL getCodeBase(final Class<?> clazz) {
|
||||
URL url = codeBaseCacheRef.get(clazz);
|
||||
if (url == null) {
|
||||
url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
|
||||
public URL run() {
|
||||
ProtectionDomain pd = clazz.getProtectionDomain();
|
||||
if (pd != null) {
|
||||
CodeSource cs = pd.getCodeSource();
|
||||
if (cs != null) {
|
||||
return cs.getLocation();
|
||||
synchronized (codeBaseCacheRef) {
|
||||
URL url = codeBaseCacheRef.get(clazz);
|
||||
if (url == null) {
|
||||
url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
|
||||
public URL run() {
|
||||
ProtectionDomain pd = clazz.getProtectionDomain();
|
||||
if (pd != null) {
|
||||
CodeSource cs = pd.getCodeSource();
|
||||
if (cs != null) {
|
||||
return cs.getLocation();
|
||||
}
|
||||
}
|
||||
return NULL_URL;
|
||||
}
|
||||
return NULL_URL;
|
||||
}
|
||||
});
|
||||
codeBaseCacheRef.put(clazz, url);
|
||||
});
|
||||
codeBaseCacheRef.put(clazz, url);
|
||||
}
|
||||
return (url == NULL_URL) ? null : url;
|
||||
}
|
||||
return (url == NULL_URL) ? null : url;
|
||||
}
|
||||
|
||||
private static void setupJurisdictionPolicies() throws Exception {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user