提交 1ccacd47 编写于 作者: R robm

8028627: Unsynchronized code path from javax.crypto.Cipher to the WeakHashMap...

8028627: Unsynchronized code path from javax.crypto.Cipher to the WeakHashMap used by JceSecurity to store codebase mappings
Reviewed-by: mullan
上级 599f76a4
/* /*
* 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. * 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
...@@ -216,26 +216,28 @@ final class JceSecurity { ...@@ -216,26 +216,28 @@ final class JceSecurity {
new WeakHashMap<>(); new WeakHashMap<>();
/* /*
* Retuns the CodeBase for the given class. * Returns the CodeBase for the given class.
*/ */
static URL getCodeBase(final Class<?> clazz) { static URL getCodeBase(final Class<?> clazz) {
URL url = codeBaseCacheRef.get(clazz); synchronized (codeBaseCacheRef) {
if (url == null) { URL url = codeBaseCacheRef.get(clazz);
url = AccessController.doPrivileged(new PrivilegedAction<URL>() { if (url == null) {
public URL run() { url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
ProtectionDomain pd = clazz.getProtectionDomain(); public URL run() {
if (pd != null) { ProtectionDomain pd = clazz.getProtectionDomain();
CodeSource cs = pd.getCodeSource(); if (pd != null) {
if (cs != null) { CodeSource cs = pd.getCodeSource();
return cs.getLocation(); 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 { private static void setupJurisdictionPolicies() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册