mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8238566: java.security.Provider$Service.supportsParameter() is racy
Use double-checked-locking pattern inside the hasKeyAttributes() method Reviewed-by: xuelei
This commit is contained in:
parent
2eaeb20697
commit
0610992a8f
1 changed files with 24 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2020, 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
|
||||
|
@ -1925,28 +1925,31 @@ public abstract class Provider extends Properties {
|
|||
Boolean b = hasKeyAttributes;
|
||||
if (b == null) {
|
||||
synchronized (this) {
|
||||
String s;
|
||||
s = getAttribute("SupportedKeyFormats");
|
||||
if (s != null) {
|
||||
supportedFormats = s.split("\\|");
|
||||
}
|
||||
s = getAttribute("SupportedKeyClasses");
|
||||
if (s != null) {
|
||||
String[] classNames = s.split("\\|");
|
||||
List<Class<?>> classList =
|
||||
new ArrayList<>(classNames.length);
|
||||
for (String className : classNames) {
|
||||
Class<?> clazz = getKeyClass(className);
|
||||
if (clazz != null) {
|
||||
classList.add(clazz);
|
||||
}
|
||||
b = hasKeyAttributes;
|
||||
if (b == null) {
|
||||
String s;
|
||||
s = getAttribute("SupportedKeyFormats");
|
||||
if (s != null) {
|
||||
supportedFormats = s.split("\\|");
|
||||
}
|
||||
supportedClasses = classList.toArray(CLASS0);
|
||||
s = getAttribute("SupportedKeyClasses");
|
||||
if (s != null) {
|
||||
String[] classNames = s.split("\\|");
|
||||
List<Class<?>> classList =
|
||||
new ArrayList<>(classNames.length);
|
||||
for (String className : classNames) {
|
||||
Class<?> clazz = getKeyClass(className);
|
||||
if (clazz != null) {
|
||||
classList.add(clazz);
|
||||
}
|
||||
}
|
||||
supportedClasses = classList.toArray(CLASS0);
|
||||
}
|
||||
boolean bool = (supportedFormats != null)
|
||||
|| (supportedClasses != null);
|
||||
b = Boolean.valueOf(bool);
|
||||
hasKeyAttributes = b;
|
||||
}
|
||||
boolean bool = (supportedFormats != null)
|
||||
|| (supportedClasses != null);
|
||||
b = Boolean.valueOf(bool);
|
||||
hasKeyAttributes = b;
|
||||
}
|
||||
}
|
||||
return b.booleanValue();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue