You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2019/06/18 15:15:41 UTC
[lucene-solr] branch master updated: LUCENE-8853: Don't return a
FileSwitchDirectory when asked for a FS directory.
This is an automated email from the ASF dual-hosted git repository.
jpountz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 2e468ab LUCENE-8853: Don't return a FileSwitchDirectory when asked for a FS directory.
2e468ab is described below
commit 2e468abecc98ffc6137fc5de2aefe8cd19cd6c8d
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Tue Jun 18 17:05:18 2019 +0200
LUCENE-8853: Don't return a FileSwitchDirectory when asked for a FS directory.
---
.../org/apache/lucene/util/LuceneTestCase.java | 24 +++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
index e5159a7..d6a875f 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
@@ -1416,11 +1416,7 @@ public abstract class LuceneTestCase extends Assert {
Directory fsdir = newFSDirectoryImpl(clazz, f, lf);
if (rarely()) {
- List<String> fileExtensions =
- Arrays.asList("fdt", "fdx", "tim", "tip", "si", "fnm", "pos", "dii", "dim", "nvm", "nvd", "dvm", "dvd");
- Collections.shuffle(fileExtensions, random());
- fileExtensions = fileExtensions.subList(0, 1 + random().nextInt(fileExtensions.size()));
- fsdir = new FileSwitchDirectory(new HashSet<>(fileExtensions), fsdir, newFSDirectoryImpl(clazz, f, lf), true);
+
}
BaseDirectoryWrapper wrapped = wrapDirectory(random(), fsdir, bare);
return wrapped;
@@ -1430,6 +1426,14 @@ public abstract class LuceneTestCase extends Assert {
}
}
+ private static Directory newFileSwitchDirectory(Random random, Directory dir1, Directory dir2) {
+ List<String> fileExtensions =
+ Arrays.asList("fdt", "fdx", "tim", "tip", "si", "fnm", "pos", "dii", "dim", "nvm", "nvd", "dvm", "dvd");
+ Collections.shuffle(fileExtensions, random);
+ fileExtensions = fileExtensions.subList(0, 1 + random.nextInt(fileExtensions.size()));
+ return new FileSwitchDirectory(new HashSet<>(fileExtensions), dir1, dir2, true);
+ }
+
/**
* Returns a new Directory instance, using the specified random
* with contents copied from the provided directory. See
@@ -1632,6 +1636,16 @@ public abstract class LuceneTestCase extends Assert {
if (clazzName.equals("random")) {
if (rarely(random)) {
clazzName = RandomPicks.randomFrom(random, CORE_DIRECTORIES);
+ } else if (rarely(random)) {
+ String clazzName1 = rarely(random)
+ ? RandomPicks.randomFrom(random, CORE_DIRECTORIES)
+ : ByteBuffersDirectory.class.getName();
+ String clazzName2 = rarely(random)
+ ? RandomPicks.randomFrom(random, CORE_DIRECTORIES)
+ : ByteBuffersDirectory.class.getName();
+ return newFileSwitchDirectory(random,
+ newDirectoryImpl(random, clazzName1, lf),
+ newDirectoryImpl(random, clazzName2, lf));
} else {
clazzName = ByteBuffersDirectory.class.getName();
}