Double check size to avoid ArrayIndexOutOfBoundsException (#9609)

Motivation:

Recycler$Stack.pop will occurs `ArrayIndexOutOfBoundsException` in some race cases, we should double check `size` even after `scavenge` called.

Modifications:

Double check `size` after `scavenge`

Result:

avoid ArrayIndexOutOfBoundsException in `pop`
This commit is contained in:
时无两丶 2019-09-27 03:53:35 +08:00 committed by Norman Maurer
parent 92941cdcac
commit 3ef00eaa06

View File

@ -511,6 +511,10 @@ public abstract class Recycler<T> {
return null;
}
size = this.size;
if (size <= 0) {
// double check, avoid races
return null;
}
}
size --;
DefaultHandle ret = elements[size];