-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Code show as below,it will overwrite the old lock with the resetLock method.Because the lock is modified by final, so it will not really be overridden.And then different lists will have conflicts of lock.
public Object clone() {
try {
@SuppressWarnings("unchecked")
CopyOnWriteArrayList<E> clone =
(CopyOnWriteArrayList<E>) super.clone();
clone.resetLock();
return clone;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
private void resetLock() {
UNSAFE.putObjectVolatile(this, lockOffset, new ReentrantLock());
}
FREQUENCY : always
Code show as below,it will overwrite the old lock with the resetLock method.Because the lock is modified by final, so it will not really be overridden.And then different lists will have conflicts of lock.
public Object clone() {
try {
@SuppressWarnings("unchecked")
CopyOnWriteArrayList<E> clone =
(CopyOnWriteArrayList<E>) super.clone();
clone.resetLock();
return clone;
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
private void resetLock() {
UNSAFE.putObjectVolatile(this, lockOffset, new ReentrantLock());
}
FREQUENCY : always