This commit is contained in:
Andrea Cavalli 2021-09-06 17:42:12 +02:00
parent e59705bd0b
commit 7230e96343

View File

@ -93,10 +93,9 @@ public class PooledIndexSearcherManager {
), ),
indexSearcher -> { indexSearcher -> {
try { try {
//noinspection SynchronizationOnLocalVariableOrMethodParameter // Mark as removed from cache
synchronized (indexSearcher) {
// Close
if (indexSearcher.removeFromCache()) { if (indexSearcher.removeFromCache()) {
// Close
try { try {
if (snapshot == null) { if (snapshot == null) {
searcherManager.release(indexSearcher.getIndexSearcher()); searcherManager.release(indexSearcher.getIndexSearcher());
@ -105,7 +104,6 @@ public class PooledIndexSearcherManager {
activeSearchers.decrementAndGet(); activeSearchers.decrementAndGet();
} }
} }
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -177,11 +175,9 @@ public class PooledIndexSearcherManager {
public Mono<Void> releaseUsedIndexSearcher(@Nullable LLSnapshot snapshot, CachedIndexSearcher indexSearcher) { public Mono<Void> releaseUsedIndexSearcher(@Nullable LLSnapshot snapshot, CachedIndexSearcher indexSearcher) {
return Mono.fromRunnable(() -> { return Mono.fromRunnable(() -> {
try { try {
synchronized (indexSearcher) {
// Decrement reference count // Decrement reference count
indexSearcher.getIndexReader().decRef();
// Close
if (indexSearcher.decUsage()) { if (indexSearcher.decUsage()) {
// Close
try { try {
if (snapshot == null) { if (snapshot == null) {
searcherManager.release(indexSearcher.getIndexSearcher()); searcherManager.release(indexSearcher.getIndexSearcher());
@ -190,7 +186,6 @@ public class PooledIndexSearcherManager {
activeSearchers.decrementAndGet(); activeSearchers.decrementAndGet();
} }
} }
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }