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 1275cfd8f8
commit 5d1414a8a9

View File

@ -508,6 +508,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];