You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2016/03/09 11:06:53 UTC

[2/2] lucene-solr git commit: LUCENE-7080: Sort files to corrupt to prevent HashSet iteration order issues across JVMs

LUCENE-7080: Sort files to corrupt to prevent HashSet iteration order issues across JVMs


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6aa9aa66
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6aa9aa66
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6aa9aa66

Branch: refs/heads/branch_6_0
Commit: 6aa9aa66e334b8c415fa6d9976bbef581ea352c9
Parents: c07bb9d
Author: Simon Willnauer <si...@apache.org>
Authored: Wed Mar 9 10:56:13 2016 +0100
Committer: Simon Willnauer <si...@apache.org>
Committed: Wed Mar 9 11:06:06 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/lucene/store/MockDirectoryWrapper.java    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6aa9aa66/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java b/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
index 962062e..7fe7c3b 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
@@ -45,6 +45,7 @@ import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.NoDeletionPolicy;
 import org.apache.lucene.index.SegmentInfos;
+import org.apache.lucene.util.CollectionUtil;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
@@ -296,7 +297,11 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
   public synchronized void corruptFiles(Collection<String> files) throws IOException {
     // Must make a copy because we change the incoming unsyncedFiles
     // when we create temp files, delete, etc., below:
-    for(String name : new ArrayList<>(files)) {
+    final List<String> filesToCorrupt = new ArrayList<>(files);
+    // sort the files otherwise we have reproducibility issues
+    // across JVMs if the incoming collection is a hashSet etc.
+    CollectionUtil.timSort(filesToCorrupt);
+    for(String name : filesToCorrupt) {
       int damage = randomState.nextInt(6);
       String action = null;