You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/31 18:30:04 UTC
[lucene-solr] branch reference_impl_dev updated: @655 Tweak around
on an object release leak.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new 6fa270d @655 Tweak around on an object release leak.
6fa270d is described below
commit 6fa270dcad1fa763eb151e86303efb46b989571d
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Mon Aug 31 13:27:01 2020 -0500
@655 Tweak around on an object release leak.
---
.../java/org/apache/solr/core/CachingDirectoryFactory.java | 13 +++++++++----
.../core/src/java/org/apache/solr/handler/IndexFetcher.java | 4 +++-
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
index 3007885..01efa6c 100644
--- a/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/CachingDirectoryFactory.java
@@ -30,10 +30,10 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockFactory;
import org.apache.lucene.util.IOUtils;
+import org.apache.solr.common.AlreadyClosedException;
import org.apache.solr.common.ParWork;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@@ -168,7 +168,7 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
}
cacheValue.doneWithDir = true;
if (log.isDebugEnabled()) log.debug("Done with dir: {}", cacheValue);
- if (cacheValue.refCnt == 0 && !closed) {
+ if (cacheValue.refCnt == 0) {
boolean cl = closeCacheValue(cacheValue);
if (cl) {
removeFromCache(cacheValue);
@@ -195,7 +195,6 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
synchronized (this) {
if (log.isDebugEnabled()) log.debug("Closing {} - {} directories currently being tracked", this.getClass().getSimpleName(), byDirectoryCache.size());
TimeOut timeout = new TimeOut(5, TimeUnit.SECONDS, TimeSource.NANO_TIME); // nocommit sensible timeout control
- this.closed = true;
Collection<CacheValue> values = byDirectoryCache.values();
for (CacheValue val : values) {
if (log.isDebugEnabled()) log.debug("Closing {} - currently tracking: {}",
@@ -224,6 +223,8 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
}
}
+ closed = true;
+
values = byDirectoryCache.values();
Set<CacheValue> closedDirs = new HashSet<>();
for (CacheValue val : values) {
@@ -433,6 +434,10 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
log.debug("get(String path={}, DirContext dirContext={}, String rawLockType={}) - start", path, dirContext, rawLockType);
}
+ if (closed) {
+ throw new AlreadyClosedException();
+ }
+
String fullPath = normalize(path);
synchronized (this) {
@@ -562,7 +567,7 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
assert cacheValue.refCnt >= 0 : cacheValue.refCnt;
- if (cacheValue.refCnt == 0 && cacheValue.doneWithDir && !closed) {
+ if (cacheValue.refCnt == 0 && cacheValue.doneWithDir) {
boolean cl = closeCacheValue(cacheValue);
if (cl) {
removeFromCache(cacheValue);
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index ba397bb..429f47a 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -873,12 +873,14 @@ public class IndexFetcher {
String tmpFileName = REPLICATION_PROPERTIES + "." + System.nanoTime();
final IndexOutput out = dir.createOutput(tmpFileName, DirectoryFactory.IOCONTEXT_NO_CACHE);
- Writer outFile = new OutputStreamWriter(new PropertiesOutputStream(out), StandardCharsets.UTF_8);
+ Writer outFile = null;
try {
+ outFile = new OutputStreamWriter(new PropertiesOutputStream(out), StandardCharsets.UTF_8);
props.store(outFile, "Replication details");
dir.sync(Collections.singleton(tmpFileName));
} finally {
ParWork.close(outFile);
+ ParWork.close(out);
}
solrCore.getDirectoryFactory().renameWithOverwrite(dir, tmpFileName, REPLICATION_PROPERTIES);