|
21 | 21 |
|
22 | 22 | import com.carrotsearch.randomizedtesting.RandomizedContext;
|
23 | 23 | import com.carrotsearch.randomizedtesting.SeedUtils;
|
| 24 | + |
24 | 25 | import org.apache.lucene.util.Accountable;
|
25 | 26 | import org.apache.lucene.util.Accountables;
|
26 | 27 | import org.apache.lucene.util.BytesRef;
|
27 |
| -import org.elasticsearch.common.settings.Settings; |
| 28 | +import org.apache.lucene.util.LuceneTestCase; |
28 | 29 | import org.elasticsearch.common.util.set.Sets;
|
29 | 30 | import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
30 | 31 | import org.elasticsearch.test.ESTestCase;
|
31 | 32 |
|
32 | 33 | import java.util.Collection;
|
33 | 34 | import java.util.Collections;
|
34 | 35 | import java.util.HashMap;
|
| 36 | +import java.util.Iterator; |
35 | 37 | import java.util.Map;
|
36 | 38 | import java.util.Random;
|
37 | 39 | import java.util.concurrent.ConcurrentHashMap;
|
@@ -59,8 +61,17 @@ public static void ensureAllArraysAreReleased() throws Exception {
|
59 | 61 | masterCopy.keySet().retainAll(ACQUIRED_ARRAYS.keySet());
|
60 | 62 | ACQUIRED_ARRAYS.keySet().removeAll(masterCopy.keySet()); // remove all existing master copy we will report on
|
61 | 63 | if (!masterCopy.isEmpty()) {
|
62 |
| - final Object cause = masterCopy.entrySet().iterator().next().getValue(); |
63 |
| - throw new RuntimeException(masterCopy.size() + " arrays have not been released", cause instanceof Throwable ? (Throwable) cause : null); |
| 64 | + Iterator<Object> causes = masterCopy.values().iterator(); |
| 65 | + Object firstCause = causes.next(); |
| 66 | + RuntimeException exception = new RuntimeException(masterCopy.size() + " arrays have not been released", |
| 67 | + firstCause instanceof Throwable ? (Throwable) firstCause : null); |
| 68 | + while (causes.hasNext()) { |
| 69 | + Object cause = causes.next(); |
| 70 | + if (cause instanceof Throwable) { |
| 71 | + exception.addSuppressed((Throwable) cause); |
| 72 | + } |
| 73 | + } |
| 74 | + throw exception; |
64 | 75 | }
|
65 | 76 | }
|
66 | 77 | }
|
@@ -249,7 +260,9 @@ private abstract static class AbstractArrayWrapper {
|
249 | 260 | AbstractArrayWrapper(boolean clearOnResize) {
|
250 | 261 | this.clearOnResize = clearOnResize;
|
251 | 262 | this.originalRelease = new AtomicReference<>();
|
252 |
| - ACQUIRED_ARRAYS.put(this, TRACK_ALLOCATIONS ? new RuntimeException() : Boolean.TRUE); |
| 263 | + ACQUIRED_ARRAYS.put(this, |
| 264 | + TRACK_ALLOCATIONS ? new RuntimeException("Unreleased array from test: " + LuceneTestCase.getTestClass().getName()) |
| 265 | + : Boolean.TRUE); |
253 | 266 | }
|
254 | 267 |
|
255 | 268 | protected abstract BigArray getDelegate();
|
|
0 commit comments