lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r923413 - in /lucene/java/branches/flex_1458/src: java/org/apache/lucene/index/LegacyFieldsEnum.java test/org/apache/lucene/index/FlexTestUtil.java
Date Mon, 15 Mar 2010 20:00:15 GMT
Author: mikemccand
Date: Mon Mar 15 20:00:15 2010
New Revision: 923413

URL: http://svn.apache.org/viewvc?rev=923413&view=rev
Log:
LUCENE-2325: fix back compat break in 'flex api on non-flex IndexReader'

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
    lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java?rev=923413&r1=923412&r2=923413&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/LegacyFieldsEnum.java
Mon Mar 15 20:00:15 2010
@@ -127,7 +127,8 @@ class LegacyFieldsEnum extends FieldsEnu
       if (terms == null) {
         // first next -- seek to start of field
         terms = r.terms(new Term(field, ""));
-        if (terms.term() == null) {
+        final Term t = terms.term();
+        if (t == null || t.field != field) {
           return null;
         } else {
           tr.copy(terms.term().text());

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java?rev=923413&r1=923412&r2=923413&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/index/FlexTestUtil.java Mon
Mar 15 20:00:15 2010
@@ -105,6 +105,16 @@ public class FlexTestUtil {
     testStraightEnum(r);
     testRandomSkips(rand, r);
     testRandomSeeks(rand, r);
+    testBogusFieldTerms(rand, r);
+  }
+
+  private static void testBogusFieldTerms(Random rand, IndexReader r) throws Exception {
+    final Fields fields = MultiFields.getFields(r);
+    for(int i=0;i<10;i++) {
+      final String f = "bogus" + rand.nextInt() + "reallybogus";
+      Terms terms = fields.terms(f);
+      assertTrue(terms == null || terms.iterator().next() == null);
+    }
   }
 
   private static void testStraightEnum(IndexReader r) throws Exception {



Mime
View raw message