Skip to content

Apache Lucene open-source search software

SOLR-3892: Inconsistent locking when accessing cache in CachingDirectoryFactory from RAMDirectoryFactory and MockDirectoryFactory.

Mark Robert Millerd503f4a31fb5
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8895d7db9db..af2e76e8f94 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -373,6 +373,9 @@ Bug Fixes
* SOLR-3891: CacheValue in CachingDirectoryFactory cannot be used outside of
solr.core package. (phunt via Mark Miller)
+
+* SOLR-3892: Inconsistent locking when accessing cache in CachingDirectoryFactory
+ from RAMDirectoryFactory and MockDirectoryFactory. (phunt via Mark Miller)
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
index 546f52ee199..19824de7ebf 100644
--- a/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
@@ -36,7 +36,7 @@ public class RAMDirectoryFactory extends StandardDirectoryFactory {
@Override
public boolean exists(String path) {
String fullPath = new File(path).getAbsolutePath();
- synchronized (DirectoryFactory.class) {
+ synchronized (this) {
CacheValue cacheValue = byPathCache.get(fullPath);
Directory directory = null;
if (cacheValue != null) {
diff --git a/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java b/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java
index 4c55dd376be..fed6fab1771 100644
--- a/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java
+++ b/solr/test-framework/src/java/org/apache/solr/core/MockDirectoryFactory.java
@@ -47,7 +47,7 @@ public class MockDirectoryFactory extends CachingDirectoryFactory {
@Override
public boolean exists(String path) {
String fullPath = new File(path).getAbsolutePath();
- synchronized (DirectoryFactory.class) {
+ synchronized (this) {
CacheValue cacheValue = byPathCache.get(fullPath);
Directory directory = null;
if (cacheValue != null) {