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:
parent
1275cfd8f8
commit
5d1414a8a9
@ -508,6 +508,10 @@ public abstract class Recycler<T> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
size = this.size;
|
size = this.size;
|
||||||
|
if (size <= 0) {
|
||||||
|
// double check, avoid races
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
size --;
|
size --;
|
||||||
DefaultHandle ret = elements[size];
|
DefaultHandle ret = elements[size];
|
||||||
|
Loading…
Reference in New Issue
Block a user