Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

disable doubleWrite check in MockDirectoryFactory, or otherwise TestReplicationHandler fails

Shai Erera2ae7bbed6da7
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 7217bdf2098..92a6b6ebc5a 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
@@ -31,21 +31,27 @@ public class MockDirectoryFactory extends EphemeralDirectoryFactory {
@Override
protected Directory create(String path) throws IOException {
Directory dir = LuceneTestCase.newDirectory();
- // we can't currently do this check because of how
- // Solr has to reboot a new Directory sometimes when replicating
- // or rolling back - the old directory is closed and the following
- // test assumes it can open an IndexWriter when that happens - we
- // have a new Directory for the same dir and still an open IW at
- // this point
if (dir instanceof MockDirectoryWrapper) {
- ((MockDirectoryWrapper)dir).setAssertNoUnrefencedFilesOnClose(false);
+ MockDirectoryWrapper mockDirWrapper = (MockDirectoryWrapper) dir;
+
+ // we can't currently do this check because of how
+ // Solr has to reboot a new Directory sometimes when replicating
+ // or rolling back - the old directory is closed and the following
+ // test assumes it can open an IndexWriter when that happens - we
+ // have a new Directory for the same dir and still an open IW at
+ // this point
+ mockDirWrapper.setAssertNoUnrefencedFilesOnClose(false);
+
+ // ram dirs in cores that are restarted end up empty
+ // and check index fails
+ mockDirWrapper.setCheckIndexOnClose(false);
+
+ // if we enable this, TestReplicationHandler fails when it
+ // tries to write to index.properties after the file has
+ // already been created.
+ mockDirWrapper.setPreventDoubleWrite(false);
}
- // ram dirs in cores that are restarted end up empty
- // and check index fails
- if (dir instanceof MockDirectoryWrapper) {
- ((MockDirectoryWrapper)dir).setCheckIndexOnClose(false);
- }
return dir;
}