Close leaked data
This commit is contained in:
parent
3a79e5ba6f
commit
5293fbe22c
@ -83,14 +83,24 @@ public class CachedIndexSearcher {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
|
boolean failedToRelease = false;
|
||||||
if (usages > 0) {
|
if (usages > 0) {
|
||||||
|
failedToRelease = true;
|
||||||
logger.error("A cached index searcher has been garbage collected, but "
|
logger.error("A cached index searcher has been garbage collected, but "
|
||||||
+ usages + " usages have not been released");
|
+ usages + " usages have not been released");
|
||||||
}
|
}
|
||||||
if (inCache) {
|
if (inCache) {
|
||||||
|
failedToRelease = true;
|
||||||
logger.error("A cached index searcher has been garbage collected, but it's marked"
|
logger.error("A cached index searcher has been garbage collected, but it's marked"
|
||||||
+ " as still actively cached");
|
+ " as still actively cached");
|
||||||
}
|
}
|
||||||
|
if (failedToRelease) {
|
||||||
|
try {
|
||||||
|
this.close();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
logger.warn("Error when closing cached index searcher", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
super.finalize();
|
super.finalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user