8146274: Thread spinning on WeakHashMap.getEntry() with concurrent use of nashorn
Reviewed-by: mhaupt, attila
This commit is contained in:
parent
07b44796c2
commit
db40a8396b
@ -54,7 +54,13 @@ public class PropertyListeners {
|
||||
*/
|
||||
PropertyListeners(final PropertyListeners listener) {
|
||||
if (listener != null && listener.listeners != null) {
|
||||
this.listeners = new WeakHashMap<>(listener.listeners);
|
||||
this.listeners = new WeakHashMap<>();
|
||||
// We need to copy the nested weak sets in order to avoid concurrent modification issues, see JDK-8146274
|
||||
synchronized (listener) {
|
||||
for (final Map.Entry<Object, WeakPropertyMapSet> entry : listener.listeners.entrySet()) {
|
||||
this.listeners.put(entry.getKey(), new WeakPropertyMapSet(entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +234,15 @@ public class PropertyListeners {
|
||||
|
||||
private static class WeakPropertyMapSet {
|
||||
|
||||
private final WeakHashMap<PropertyMap, Boolean> map = new WeakHashMap<>();
|
||||
private final WeakHashMap<PropertyMap, Boolean> map;
|
||||
|
||||
WeakPropertyMapSet() {
|
||||
this.map = new WeakHashMap<>();
|
||||
}
|
||||
|
||||
WeakPropertyMapSet(final WeakPropertyMapSet set) {
|
||||
this.map = new WeakHashMap<>(set.map);
|
||||
}
|
||||
|
||||
void add(final PropertyMap propertyMap) {
|
||||
map.put(propertyMap, Boolean.TRUE);
|
||||
|
@ -24,7 +24,7 @@ Object.preventExtensions=prevents new properties from ever being added to the gi
|
||||
|
||||
Object.isSealed=tells if an object is sealed or not
|
||||
|
||||
Object.isFrozen=tells if an object is fronzen or not
|
||||
Object.isFrozen=tells if an object is frozen or not
|
||||
|
||||
Object.isExtensible=tells if an object is extensible or not
|
||||
|
||||
@ -32,7 +32,7 @@ Object.keys=returns an array of the given object's own enumerable properties
|
||||
|
||||
Object=creates a new script object or converts given value as a script object
|
||||
|
||||
Object.prototype.toString=returns a string representing of this object
|
||||
Object.prototype.toString=returns a string representation of this object
|
||||
|
||||
Object.prototype.hasOwnProperty=tells whether this object has the specified property or not
|
||||
|
||||
@ -42,3 +42,12 @@ Object.prototype.propertyIsEnumerable=tells whether the given property is enumer
|
||||
|
||||
Object.bindProperties=binds the source object's properties to the target object (nashorn extension)
|
||||
|
||||
Function=creates a new function with the given parameters and function body
|
||||
|
||||
Function.prototype.toString=returns a string representation of this function
|
||||
|
||||
Function.prototype.apply=invokes the function with the given this-reference and arguments array
|
||||
|
||||
Function.prototype.call=invokes the function with the given this-reference and arguments
|
||||
|
||||
Function.prototype.bind=returns a new function with bound this-reference and arguments
|
||||
|
Loading…
x
Reference in New Issue
Block a user