You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2019/02/20 11:45:35 UTC

[lucene-solr] branch branch_7_7 updated (71bdc18 -> a1353b6)

This is an automated email from the ASF dual-hosted git repository.

noble pushed a change to branch branch_7_7
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


    from 71bdc18  Ref Guide: fix "cloud mode" to "SolrCloud mode"
     new 7f2ec0b  SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression  in release 7.7
     new a1353b6  SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression  in release 7.7

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   | 19 +++++++
 ...nguageIdentifierUpdateProcessorFactoryTest.java | 31 ++++++++++-
 .../org/apache/solr/update/DocumentBuilder.java    |  6 ++-
 .../org/apache/solr/common/SolrInputField.java     | 61 +++++++++++++++++++---
 .../common/util/ByteArrayUtf8CharSequence.java     |  5 ++
 .../org/apache/solr/common/util/JavaBinCodec.java  |  2 +-
 6 files changed, 114 insertions(+), 10 deletions(-)


[lucene-solr] 01/02: SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression in release 7.7

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch branch_7_7
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 7f2ec0b46667a85b1b755b1f1b4a0c882b44b7ce
Author: Noble Paul <no...@apache.org>
AuthorDate: Wed Feb 20 22:19:18 2019 +1100

    SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression  in release 7.7
---
 .../org/apache/solr/update/DocumentBuilder.java    |  6 ++-
 .../org/apache/solr/common/SolrInputField.java     | 61 +++++++++++++++++++---
 .../common/util/ByteArrayUtf8CharSequence.java     |  5 ++
 .../org/apache/solr/common/util/JavaBinCodec.java  |  2 +-
 4 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java b/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
index 2fd0266..541e664 100644
--- a/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
+++ b/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
@@ -135,7 +135,7 @@ public class DocumentBuilder {
     // Load fields from SolrDocument to Document
     for( SolrInputField field : doc ) {
 
-      if (field.getFirstValue() instanceof SolrDocumentBase) {
+      if (field.getFirstRawValue() instanceof SolrDocumentBase) {
         if (ignoreNestedDocs) {
           continue;
         }
@@ -159,7 +159,9 @@ public class DocumentBuilder {
       // load each field value
       boolean hasField = false;
       try {
-        for( Object v : field ) {
+        Iterator it = field.getRawIterator();
+        while (it.hasNext()) {
+          Object v = it.next();
           if( v == null ) {
             continue;
           }
diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
index 5d99d92..8b4add6 100644
--- a/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
+++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
@@ -21,6 +21,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
+import static org.apache.solr.common.util.ByteArrayUtf8CharSequence.convertCharSeq;
+
 /**
  *
  * @since solr 1.3
@@ -111,11 +113,11 @@ public class SolrInputField implements Iterable<Object>, Serializable
     if( value instanceof Collection ) {
       Collection c = (Collection<Object>)value;
       if( c.size() > 0 ) {
-        return c.iterator().next();
+        return convertCharSeq(c.iterator().next());
       }
       return null;
     }
-    return value;
+    return convertCharSeq(value);
   }
 
   /**
@@ -123,6 +125,28 @@ public class SolrInputField implements Iterable<Object>, Serializable
    * will be a collection.
    */
   public Object getValue() {
+    return convertCharSeq(value);
+  }
+
+
+  /**
+   * Return a value as is without converting and CharSequence Objects
+   */
+  public Object getRawValue() {
+    return value;
+  }
+
+  /**
+   * Return the first value as is without converting and CharSequence Objects
+   */
+  public Object getFirstRawValue() {
+    if (value instanceof Collection) {
+      Collection c = (Collection<Object>) value;
+      if (c.size() > 0) {
+        return c.iterator().next();
+      }
+      return null;
+    }
     return value;
   }
 
@@ -132,12 +156,12 @@ public class SolrInputField implements Iterable<Object>, Serializable
    */
   @SuppressWarnings("unchecked")
   public Collection<Object> getValues() {
-    if( value instanceof Collection ) {
-      return (Collection<Object>)value;
+    if (value instanceof Collection) {
+      return convertCharSeq((Collection<Object>) value);
     }
     if( value != null ) {
       Collection<Object> vals = new ArrayList<>(1);
-      vals.add( value );
+      vals.add(convertCharSeq(value));
       return vals;
     }
     return null;
@@ -165,8 +189,33 @@ public class SolrInputField implements Iterable<Object>, Serializable
   }
 
   @Override
+  public Iterator<Object> iterator(){
+    if( value instanceof Collection ) {
+      return (convertCharSeq ((Collection)value)).iterator();
+    }
+    return new Iterator<Object>() {
+      boolean nxt = (value!=null);
+
+      @Override
+      public boolean hasNext() {
+        return nxt;
+      }
+
+      @Override
+      public Object next() {
+        nxt = false;
+        return convertCharSeq(value);
+      }
+
+      @Override
+      public void remove() {
+        throw new UnsupportedOperationException();
+      }
+    };
+
+  }
   @SuppressWarnings("unchecked")
-  public Iterator<Object> iterator() {
+  public Iterator<Object> getRawIterator() {
     if( value instanceof Collection ) {
       return ((Collection)value).iterator();
     }
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java b/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java
index c9a05cb..7a4abe2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ByteArrayUtf8CharSequence.java
@@ -73,6 +73,10 @@ public class ByteArrayUtf8CharSequence implements Utf8CharSequence {
     return buf[offset + idx];
   }
 
+  /**
+   * this is for internal use to get a cached string value.
+   * returns null if There is no cached String value
+   */
   public String getStringOrNull() {
     return utf16;
   }
@@ -209,6 +213,7 @@ public class ByteArrayUtf8CharSequence implements Utf8CharSequence {
   public static Object convertCharSeq(Object o) {
     if (o == null) return null;
     if (o instanceof Utf8CharSequence) return ((Utf8CharSequence) o).toString();
+    if (o instanceof Collection) return convertCharSeq((Collection) o);
     return o;
   }
 
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
index 782d109..905f6b9 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
@@ -357,7 +357,7 @@ public class JavaBinCodec implements PushWriter {
       return true;
     }
     if (val instanceof SolrInputField) {
-      return writeKnownType(((SolrInputField) val).getValue());
+      return writeKnownType(((SolrInputField) val).getRawValue());
     }
     if (val instanceof IteratorWriter) {
       writeIterator((IteratorWriter) val);


[lucene-solr] 02/02: SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression in release 7.7

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch branch_7_7
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit a1353b6a94fa4d02d397f8fc2965dc6ce82ed42a
Author: Noble Paul <no...@apache.org>
AuthorDate: Wed Feb 20 22:43:58 2019 +1100

    SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression  in release 7.7
---
 solr/CHANGES.txt                                   | 19 +++++++++++++
 ...nguageIdentifierUpdateProcessorFactoryTest.java | 31 +++++++++++++++++++++-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 74057fe..a4cd348 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -31,6 +31,25 @@ Jetty 9.4.14.v20181114
 
 (No Changes)
 
+==================  7.7.1 ==================
+
+Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
+
+Versions of Major Components
+---------------------
+Apache Tika 1.19.1
+Carrot2 3.16.0
+Velocity 1.7 and Velocity Tools 2.0
+Apache ZooKeeper 3.4.13
+Jetty 9.4.14.v20181114
+
+
+Bug Fixes
+----------------------
+
+* SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression
+  in release 7.7 (noble)
+
 
 ==================  7.7.0 ==================
 
diff --git a/solr/contrib/langid/src/test/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessorFactoryTest.java b/solr/contrib/langid/src/test/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessorFactoryTest.java
index e7d3c15..057cbe7 100644
--- a/solr/contrib/langid/src/test/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessorFactoryTest.java
+++ b/solr/contrib/langid/src/test/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessorFactoryTest.java
@@ -16,14 +16,43 @@
  */
 package org.apache.solr.update.processor;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.ByteArrayUtf8CharSequence;
 import org.junit.Test;
 
 public class LangDetectLanguageIdentifierUpdateProcessorFactoryTest extends LanguageIdentifierUpdateProcessorFactoryTestCase {
   @Override
   protected LanguageIdentifierUpdateProcessor createLangIdProcessor(ModifiableSolrParams parameters) throws Exception {
-    return new LangDetectLanguageIdentifierUpdateProcessor(_parser.buildRequestFrom(h.getCore(), parameters, null), resp, null);
+    return new LangDetectLanguageIdentifierUpdateProcessor(_parser.buildRequestFrom(h.getCore(), parameters, null), resp, null){
+       public SolrInputDocument process(SolrInputDocument origDoc) {
+        SolrInputDocument modifiedDoc = origDoc.deepCopy();
+        if (random().nextBoolean()) {
+          modifiedDoc.forEach((s, f) -> {
+            Object rawVal = f.getRawValue();
+            if (rawVal instanceof Collection) {
+              Collection rawValue = (Collection) rawVal;
+              ArrayList<Object> newVal = new ArrayList<>(rawValue.size());
+              for (Object o : rawValue) {
+                if (o instanceof String) {
+                  newVal.add(new ByteArrayUtf8CharSequence((String) o));
+                } else {
+                  newVal.add(rawVal);
+                }
+              }
+              f.setValue(newVal);
+            } else if (rawVal instanceof String) {
+              f.setValue(new ByteArrayUtf8CharSequence((String) rawVal));
+            }
+          });
+        }
+        super.process(modifiedDoc);
+        return modifiedDoc;
+      }
+    };
   }
   
   // this one actually works better it seems with short docs