File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
src/test/java/org/elasticsearch/test/engine Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,13 @@ public final class AssertingSearcher implements Searcher {
97
97
private final ShardId shardId ;
98
98
private RuntimeException firstReleaseStack ;
99
99
private final Object lock = new Object ();
100
+ private final int initialRefCount ;
100
101
101
102
public AssertingSearcher (Searcher searcher , ShardId shardId ) {
102
103
this .searcher = searcher ;
103
104
this .shardId = shardId ;
105
+ initialRefCount = searcher .reader ().getRefCount ();
106
+ assert initialRefCount > 0 : "IndexReader#getRefCount() was [" + initialRefCount + "] expected a value > [0] - reader is already closed" ;
104
107
INFLIGHT_ENGINE_SEARCHERS .put (this , new RuntimeException ("Unreleased Searcher, source [" + searcher .source () + "]" ));
105
108
}
106
109
@@ -124,6 +127,10 @@ public boolean release() throws ElasticSearchException {
124
127
firstReleaseStack = new RuntimeException ("Searcher Released first here, source [" + searcher .source () + "]" );
125
128
}
126
129
}
130
+ final int refCount = searcher .reader ().getRefCount ();
131
+ // this assert seems to be paranoid but given LUCENE-5362 we better add some assertions here to make sure we catch any potential
132
+ // problems.
133
+ assert refCount > 0 : "IndexReader#getRefCount() was [" + refCount + "] expected a value > [0] - reader is already closed. Initial refCount was: [" + initialRefCount + "]" ;
127
134
try {
128
135
return searcher .release ();
129
136
} catch (RuntimeException ex ) {
You can’t perform that action at this time.
0 commit comments