Fix nullptr exception on calling clear(d) with d being null (Thx @HyperSoop)

This commit is contained in:
TomTheFurry
2022-03-14 14:36:42 +08:00
parent fbd8f48433
commit f1eb06bbb1
@@ -32,24 +32,17 @@ public class MovableGridRingList<T> extends ArrayList<T> implements List<T> {
@Override
public void clear() {
moveLock.writeLock().lock();
try {
super.clear();
super.ensureCapacity(size*size);
for (int i=0; i<size*size; i++) {
super.add(null);
}
} finally {
moveLock.writeLock().unlock();
}
clear(null);
}
public void clear(Consumer<? super T> d) {
moveLock.writeLock().lock();
try {
super.forEach((t) -> {
if (t!=null) d.accept(t);
});
if (d != null) {
super.forEach((t) -> {
if (t!=null) d.accept(t);
});
}
super.clear();
super.ensureCapacity(size*size);
for (int i=0; i<size*size; i++) {