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 2020/01/06 13:44:29 UTC
[lucene-solr] branch master updated: LUCENE-8673: Avoid OOMEs
because of IOContext randomization.
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 b6f3183 LUCENE-8673: Avoid OOMEs because of IOContext randomization.
b6f3183 is described below
commit b6f31835ad18da0f7a22064481b0d0e167f9f30c
Author: Adrien Grand <jp...@gmail.com>
AuthorDate: Mon Jan 6 14:43:13 2020 +0100
LUCENE-8673: Avoid OOMEs because of IOContext randomization.
---
.../java/org/apache/lucene/util/LuceneTestCase.java | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 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 545b57b..213d7d7 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
@@ -1332,7 +1332,7 @@ public abstract class LuceneTestCase extends Assert {
* See {@link #newDirectory()} for more information.
*/
public static BaseDirectoryWrapper newDirectory(Random r) {
- return wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY), rarely(r));
+ return wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY), rarely(r), false);
}
/**
@@ -1340,7 +1340,7 @@ public abstract class LuceneTestCase extends Assert {
* See {@link #newDirectory()} for more information.
*/
public static BaseDirectoryWrapper newDirectory(Random r, LockFactory lf) {
- return wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY, lf), rarely(r));
+ return wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY, lf), rarely(r), false);
}
public static MockDirectoryWrapper newMockDirectory() {
@@ -1348,11 +1348,11 @@ public abstract class LuceneTestCase extends Assert {
}
public static MockDirectoryWrapper newMockDirectory(Random r) {
- return (MockDirectoryWrapper) wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY), false);
+ return (MockDirectoryWrapper) wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY), false, false);
}
public static MockDirectoryWrapper newMockDirectory(Random r, LockFactory lf) {
- return (MockDirectoryWrapper) wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY, lf), false);
+ return (MockDirectoryWrapper) wrapDirectory(r, newDirectoryImpl(r, TEST_DIRECTORY, lf), false, false);
}
public static MockDirectoryWrapper newMockFSDirectory(Path f) {
@@ -1416,10 +1416,7 @@ public abstract class LuceneTestCase extends Assert {
}
Directory fsdir = newFSDirectoryImpl(clazz, f, lf);
- if (rarely()) {
-
- }
- BaseDirectoryWrapper wrapped = wrapDirectory(random(), fsdir, bare);
+ BaseDirectoryWrapper wrapped = wrapDirectory(random(), fsdir, bare, true);
return wrapped;
} catch (Exception e) {
Rethrow.rethrow(e);
@@ -1447,11 +1444,13 @@ public abstract class LuceneTestCase extends Assert {
impl.copyFrom(d, file, file, newIOContext(r));
}
}
- return wrapDirectory(r, impl, rarely(r));
+ return wrapDirectory(r, impl, rarely(r), false);
}
- private static BaseDirectoryWrapper wrapDirectory(Random random, Directory directory, boolean bare) {
- if (rarely(random) && !bare) {
+ private static BaseDirectoryWrapper wrapDirectory(Random random, Directory directory, boolean bare, boolean filesystem) {
+ // IOContext randomization might make NRTCachingDirectory make bad decisions, so avoid
+ // using it if the user requested a filesystem directory.
+ if (rarely(random) && !bare && filesystem == false) {
directory = new NRTCachingDirectory(directory, random.nextDouble(), random.nextDouble());
}