lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1394844 - in /lucene/dev/branches/lucene_solr_4_0: ./ dev-tools/ lucene/ lucene/analysis/ lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/backwards/ lucene/benchmark/ lucene/codecs/ lucene/core/ lucene/core/src/test/org/ap...
Date Fri, 05 Oct 2012 22:26:38 GMT
Author: hossman
Date: Fri Oct  5 22:26:36 2012
New Revision: 1394844

URL: http://svn.apache.org/viewvc?rev=1394844&view=rev
Log:
SOLR-3916: Fixed whitespace bug in parsing the fl param  (merge r1394836)

Modified:
    lucene/dev/branches/lucene_solr_4_0/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/dev-tools/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/BUILD.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/CHANGES.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/JRE_VERSION_MIGRATION.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/LICENSE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/MIGRATE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/README.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/analysis/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java
  (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/backwards/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/benchmark/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/build.xml   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/codecs/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/common-build.xml   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/core/src/test/org/apache/lucene/index/index.40.cfs.zip
  (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/core/src/test/org/apache/lucene/index/index.40.nocfs.zip
  (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.cfs.zip
  (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.nocfs.zip
  (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/demo/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/facet/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/grouping/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/highlighter/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/ivy-settings.xml   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/join/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/licenses/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/memory/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/misc/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/module-build.xml   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/queries/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/queryparser/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/sandbox/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/site/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/spatial/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/suggest/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
    lucene/dev/branches/lucene_solr_4_0/lucene/tools/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/LICENSE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/README.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/build.xml   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/cloud-dev/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/common-build.xml   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/contrib/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/search/ReturnFields.java
    lucene/dev/branches/lucene_solr_4_0/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
    lucene/dev/branches/lucene_solr_4_0/solr/example/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/httpclient-LICENSE-ASL.txt   (props
changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/httpclient-NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/httpcore-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/httpcore-NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/httpmime-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/licenses/httpmime-NOTICE.txt   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/scripts/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/site/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/solrj/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/test-framework/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/testlogging.properties   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/webapp/   (props changed)

Modified: lucene/dev/branches/lucene_solr_4_0/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java?rev=1394844&r1=1394843&r2=1394844&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
(original)
+++ lucene/dev/branches/lucene_solr_4_0/lucene/test-framework/src/java/org/apache/lucene/util/_TestUtil.java
Fri Oct  5 22:26:36 2012
@@ -975,4 +975,53 @@ public class _TestUtil {
       }
     }
   }
+  /**
+   * Returns a random string in the specified length range consisting 
+   * entirely of whitespace characters 
+   * @see #WHITESPACE_CHARACTERS
+   */
+  public static String randomWhitespace(Random r, int minLength, int maxLength) {
+    final int end = nextInt(r, minLength, maxLength);
+    StringBuilder out = new StringBuilder();
+    for (int i = 0; i < end; i++) {
+      int offset = nextInt(r, 0, WHITESPACE_CHARACTERS.length-1);
+      char c = WHITESPACE_CHARACTERS[offset];
+      // sanity check
+      Assert.assertTrue("Not really whitespace? (@"+offset+"): " + c, Character.isWhitespace(c));
+      out.append(c);
+    }
+    return out.toString();
+  }
+  
+  /** List of characters that match {@link Character#isWhitespace} */
+  public static final char[] WHITESPACE_CHARACTERS = new char[] {
+    // :TODO: is this list exhaustive?
+    '\u0009',
+    '\n',    
+    '\u000B',
+    '\u000C',
+    '\r',    
+    '\u001C',
+    '\u001D',
+    '\u001E',
+    '\u001F',
+    '\u0020',
+    // '\u0085', faild sanity check?
+    '\u1680',
+    '\u180E',
+    '\u2000',
+    '\u2001',
+    '\u2002',
+    '\u2003',
+    '\u2004',
+    '\u2005',
+    '\u2006',
+    '\u2008',
+    '\u2009',
+    '\u200A',
+    '\u2028',
+    '\u2029',
+    '\u205F',
+    '\u3000',
+  };
 }

Modified: lucene/dev/branches/lucene_solr_4_0/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/solr/CHANGES.txt?rev=1394844&r1=1394843&r2=1394844&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_0/solr/CHANGES.txt Fri Oct  5 22:26:36 2012
@@ -354,6 +354,8 @@ Bug Fixes
 * SOLR-3903: Fixed MissingFormatArgumentException in ConcurrentUpdateSolrServer
   (hossman)
 
+* SOLR-3916: Fixed whitespace bug in parsing the fl param (hossman)
+
 Other Changes
 ----------------------
 

Modified: lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/search/ReturnFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/search/ReturnFields.java?rev=1394844&r1=1394843&r2=1394844&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/search/ReturnFields.java
(original)
+++ lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/search/ReturnFields.java
Fri Oct  5 22:26:36 2012
@@ -201,7 +201,7 @@ public class ReturnFields
             sp.eatws();
             start = sp.pos;
           } else {
-            if (ch==' ' || ch == ',' || ch==0) {
+            if (Character.isWhitespace(ch) || ch == ',' || ch==0) {
               addField( field, key, augmenters, req );
               continue;
             }
@@ -215,7 +215,7 @@ public class ReturnFields
           // we read "key : "
           field = sp.getId(null);
           ch = sp.ch();
-          if (field != null && (ch==' ' || ch == ',' || ch==0)) {
+          if (field != null && (Character.isWhitespace(ch) || ch == ',' || ch==0))
{
             rename.add(field, key);
             addField( field, key, augmenters, req );
             continue;
@@ -231,7 +231,7 @@ public class ReturnFields
 
           field = sp.getGlobbedId(null);
           ch = sp.ch();
-          if (field != null && (ch==' ' || ch == ',' || ch==0)) {
+          if (field != null && (Character.isWhitespace(ch) || ch == ',' || ch==0))
{
             // "*" looks and acts like a glob, but we give it special treatment
             if ("*".equals(field)) {
               _wantsAllFields = true;

Modified: lucene/dev/branches/lucene_solr_4_0/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java?rev=1394844&r1=1394843&r2=1394844&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
(original)
+++ lucene/dev/branches/lucene_solr_4_0/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java
Fri Oct  5 22:26:36 2012
@@ -21,9 +21,13 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.transform.*;
+
+import org.apache.lucene.util._TestUtil;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.util.Random;
 
 public class ReturnFieldsTest extends SolrTestCaseJ4 {
 
@@ -302,4 +306,38 @@ public class ReturnFieldsTest extends So
     assertFalse(rf.wantsField("xxx"));
     assertFalse(rf.wantsAllFields());
   }
+
+  public void testWhitespace() {
+    Random r = random();
+    final int iters = atLeast(30);
+
+    for (int i = 0; i < iters; i++) {
+      final boolean aliasId = r.nextBoolean();
+      final boolean aliasFoo = r.nextBoolean();
+
+      final String id = _TestUtil.randomWhitespace(r, 0, 3) + 
+        (aliasId ? "aliasId:" : "") +
+        "id" + 
+        _TestUtil.randomWhitespace(r, 1, 3);
+      final String foo_i = _TestUtil.randomWhitespace(r, 0, 3) + 
+        (aliasFoo ? "aliasFoo:" : "") +
+        "foo_i" + 
+        _TestUtil.randomWhitespace(r, 0, 3);
+
+      final String fl = id + (r.nextBoolean() ? "" : ",") + foo_i;
+      ReturnFields rf = new ReturnFields(req("fl", fl));
+
+      assertFalse("score ("+fl+")", rf.wantsScore());
+
+      assertTrue("id ("+fl+")", rf.wantsField("id"));
+      assertTrue("foo_i ("+fl+")", rf.wantsField("foo_i"));
+
+      assertEquals("aliasId ("+fl+")", aliasId, rf.wantsField("aliasId"));
+      assertEquals("aliasFoo ("+fl+")", aliasFoo, rf.wantsField("aliasFoo"));
+
+      assertFalse(rf.wantsField("xxx"));
+      assertFalse(rf.wantsAllFields());
+    }
+  }
+
 }



Mime
View raw message