This commit is contained in:
Andrea Cavalli 2021-09-23 22:04:01 +02:00
parent 3a544d4297
commit 1a73a5a33f
2 changed files with 9 additions and 8 deletions

View File

@ -19,13 +19,12 @@ public abstract class LiveResourceSupport<I extends Resource<I>, T extends LiveR
@Override
protected void finalize() throws Throwable {
if (this.isAccessible()) {
var ise = new IllegalStateException("Resource not released");
ise.setStackTrace(new StackTraceElement[0]);
logger.error("Resource not released: {}", this, attachTrace(ise));
try {
this.close();
} catch (Throwable ignored) {
} finally {
var ise = new IllegalStateException("Resource not released");
ise.setStackTrace(new StackTraceElement[0]);
logger.error("Resource not released: {}", this, attachTrace(ise));
}
}
super.finalize();

View File

@ -24,7 +24,7 @@ public class SimpleUnsortedUnscoredLuceneMultiSearcher implements LuceneMultiSea
LocalQueryParams queryParams,
String keyFieldName,
LLSearchTransformer transformer) {
var indexSearchersResource = Mono
var indexSearchersSendResource = Mono
.fromRunnable(() -> {
LLUtils.ensureBlocking();
if (queryParams.isSorted() && queryParams.limit() > 0) {
@ -36,11 +36,12 @@ public class SimpleUnsortedUnscoredLuceneMultiSearcher implements LuceneMultiSea
+ " by SimpleUnsortedUnscoredLuceneMultiSearcher");
}
})
.then(indexSearchersMono.map(Send::receive));
.then(indexSearchersMono);
var localQueryParams = getLocalQueryParams(queryParams);
return LLUtils.usingResource(indexSearchersResource,
indexSearchers -> Flux.fromIterable(indexSearchers.shards())
return LLUtils.usingSendResource(indexSearchersSendResource,
indexSearchers -> Flux
.fromIterable(indexSearchers.shards())
.flatMap(searcher -> {
var llSearcher = Mono.fromCallable(() -> new LLIndexSearcher(searcher, d -> {}).send());
return localSearcher.collect(llSearcher, localQueryParams, keyFieldName, transformer);
@ -69,6 +70,7 @@ public class SimpleUnsortedUnscoredLuceneMultiSearcher implements LuceneMultiSea
for (LuceneSearchResult luceneSearchResult : resultsToDrop) {
luceneSearchResult.close();
}
indexSearchers.close();
}).send();
}),
false