MockBigArrays should tell you who originally released them
This commit is contained in:
parent
f96ea58db8
commit
bc8ad8de5a
|
@ -24,7 +24,6 @@ import com.carrotsearch.randomizedtesting.SeedUtils;
|
|||
import org.apache.lucene.util.Accountable;
|
||||
import org.apache.lucene.util.Accountables;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
|
@ -39,7 +38,7 @@ import java.util.Set;
|
|||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class MockBigArrays extends BigArrays {
|
||||
|
||||
|
@ -250,13 +249,13 @@ public class MockBigArrays extends BigArrays {
|
|||
|
||||
final BigArray in;
|
||||
boolean clearOnResize;
|
||||
AtomicBoolean released;
|
||||
AtomicReference<AssertionError> originalRelease;
|
||||
|
||||
AbstractArrayWrapper(BigArray in, boolean clearOnResize) {
|
||||
ACQUIRED_ARRAYS.put(this, TRACK_ALLOCATIONS ? new RuntimeException() : Boolean.TRUE);
|
||||
this.in = in;
|
||||
this.clearOnResize = clearOnResize;
|
||||
released = new AtomicBoolean(false);
|
||||
originalRelease = new AtomicReference<>();
|
||||
}
|
||||
|
||||
protected abstract BigArray getDelegate();
|
||||
|
@ -272,8 +271,8 @@ public class MockBigArrays extends BigArrays {
|
|||
}
|
||||
|
||||
public void close() {
|
||||
if (!released.compareAndSet(false, true)) {
|
||||
throw new IllegalStateException("Double release");
|
||||
if (originalRelease.compareAndSet(null, new AssertionError()) == false) {
|
||||
throw new IllegalStateException("Double release. Original release attached as cause", originalRelease.get());
|
||||
}
|
||||
ACQUIRED_ARRAYS.remove(this);
|
||||
randomizeContent(0, size());
|
||||
|
|
Loading…
Reference in New Issue