You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/04/11 00:18:06 UTC

svn commit: r1466714 - /lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java

Author: mikemccand
Date: Wed Apr 10 22:18:06 2013
New Revision: 1466714

URL: http://svn.apache.org/r1466714
Log:
fix test to stop if indexing threads hits an exception

Modified:
    lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java

Modified: lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java?rev=1466714&r1=1466713&r2=1466714&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java (original)
+++ lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/search/TestSearcherTaxonomyManager.java Wed Apr 10 22:18:06 2013
@@ -54,42 +54,45 @@ public class TestSearcherTaxonomyManager
     Thread indexer = new Thread() {
         @Override
         public void run() {
-          Set<String> seen = new HashSet<String>();
-          List<String> paths = new ArrayList<String>();
-          while (true) {
-            Document doc = new Document();
-            List<CategoryPath> docPaths = new ArrayList<CategoryPath>();
-            int numPaths = _TestUtil.nextInt(random(), 1, 5);
-            for(int i=0;i<numPaths;i++) {
-              String path;
-              if (!paths.isEmpty() && random().nextInt(5) != 4) {
-                // Use previous path
-                path = paths.get(random().nextInt(paths.size()));
-              } else {
-                // Create new path
-                path = null;
-                while (true) {
-                  path = _TestUtil.randomRealisticUnicodeString(random());
-                  if (path.length() != 0 && !seen.contains(path) && path.indexOf(FacetIndexingParams.DEFAULT_FACET_DELIM_CHAR) == -1) {
-                    seen.add(path);
-                    paths.add(path);
-                    break;
+          try {
+            Set<String> seen = new HashSet<String>();
+            List<String> paths = new ArrayList<String>();
+            while (true) {
+              Document doc = new Document();
+              List<CategoryPath> docPaths = new ArrayList<CategoryPath>();
+              int numPaths = _TestUtil.nextInt(random(), 1, 5);
+              for(int i=0;i<numPaths;i++) {
+                String path;
+                if (!paths.isEmpty() && random().nextInt(5) != 4) {
+                  // Use previous path
+                  path = paths.get(random().nextInt(paths.size()));
+                } else {
+                  // Create new path
+                  path = null;
+                  while (true) {
+                    path = _TestUtil.randomRealisticUnicodeString(random());
+                    if (path.length() != 0 && !seen.contains(path) && path.indexOf(FacetIndexingParams.DEFAULT_FACET_DELIM_CHAR) == -1) {
+                      seen.add(path);
+                      paths.add(path);
+                      break;
+                    }
                   }
                 }
+                docPaths.add(new CategoryPath("field", path));
+              }
+              try {
+                facetFields.addFields(doc, docPaths);
+                w.addDocument(doc);
+              } catch (IOException ioe) {
+                throw new RuntimeException(ioe);
               }
-              docPaths.add(new CategoryPath("field", path));
-            }
-            try {
-              facetFields.addFields(doc, docPaths);
-              w.addDocument(doc);
-            } catch (IOException ioe) {
-              throw new RuntimeException(ioe);
-            }
 
-            if (tw.getSize() >= ordLimit) {
-              stop.set(true);
-              break;
+              if (tw.getSize() >= ordLimit) {
+                break;
+              }
             }
+          } finally {
+            stop.set(true);
           }
         }
       };