You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2015/04/09 06:46:22 UTC

svn commit: r1672239 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/schema/ solr/core/src/test/org/apache/solr/cloud/ solr/example/ solr/example/exampledocs/

Author: sarowe
Date: Thu Apr  9 04:46:21 2015
New Revision: 1672239

URL: http://svn.apache.org/r1672239
Log:
SOLR-7366: fix regression in ManagedIndexSchema's handling of ResourceLoaderAware objects used by field types, causing example XML docs to not be indexable via bin/post; add a test indexing example docs that fails without the patch and succeeds with it (merged trunk r1672238)

Added:
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
      - copied unchanged from r1672238, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
    lucene/dev/branches/branch_5x/solr/example/   (props changed)
    lucene/dev/branches/branch_5x/solr/example/exampledocs/ipod_other.xml

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1672239&r1=1672238&r2=1672239&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Thu Apr  9 04:46:21 2015
@@ -349,6 +349,9 @@ Bug Fixes
 * SOLR-7338, SOLR-6583: A reloaded core will never register itself as active after a ZK session expiration
   (Mark Miller, Timothy Potter)
 
+* SOLR-7366: Can't index example XML docs into the cloud example using bin/post due to regression in 
+  ManagedIndexSchema's handling of ResourceLoaderAware objects used by field types (Steve Rowe, Timothy Potter)
+
 * SOLR-7284: HdfsUpdateLog is using hdfs FileSystem.get without turning off the cache.
   (Mark Miller)
   

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java?rev=1672239&r1=1672238&r2=1672239&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java Thu Apr  9 04:46:21 2015
@@ -590,10 +590,8 @@ public class IndexSchema {
       dynamicCopyFields = new DynamicCopy[] {};
       loadCopyFields(document, xpath);
 
-      //Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : schemaAware) {
-        aware.inform(this);
-      }
+      postReadInform();
+
     } catch (SolrException e) {
       throw new SolrException(ErrorCode.getErrorCode(e.code()), e.getMessage() + ". Schema file is " +
           resourcePath, e);
@@ -607,6 +605,13 @@ public class IndexSchema {
     // create the field analyzers
     refreshAnalyzers();
   }
+  
+  protected void postReadInform() {
+    //Run the callbacks on SchemaAware now that everything else is done
+    for (SchemaAware aware : schemaAware) {
+      aware.inform(this);
+    }
+  }
 
   /** 
    * Loads fields and dynamic fields.

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java?rev=1672239&r1=1672238&r2=1672239&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java Thu Apr  9 04:46:21 2015
@@ -41,7 +41,6 @@ import org.apache.solr.common.params.Mod
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.ContentStream;
 import org.apache.solr.common.util.NamedList;
-import org.apache.solr.core.Config;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrResourceLoader;
 import org.apache.solr.rest.schema.FieldTypeXmlAdapter;
@@ -50,13 +49,8 @@ import org.apache.solr.util.FileUtils;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.data.Stat;
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -418,10 +412,8 @@ public final class ManagedIndexSchema ex
         }
       }
 
-      // Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
+
       newSchema.refreshAnalyzers();
 
       if(persist) {
@@ -468,10 +460,7 @@ public final class ManagedIndexSchema ex
           throw new SolrException(ErrorCode.BAD_REQUEST, msg);
         }
       }
-      // Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -555,9 +544,7 @@ public final class ManagedIndexSchema ex
         }
       }
 
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -595,10 +582,7 @@ public final class ManagedIndexSchema ex
         }
       }
 
-      // Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
       if (persist) {
         success = newSchema.persistManagedSchema(false); // don't just create - update it if it already exists
@@ -677,10 +661,7 @@ public final class ManagedIndexSchema ex
         }
       }
 
-      // Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -748,9 +729,7 @@ public final class ManagedIndexSchema ex
         }
       }
 
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -773,11 +752,7 @@ public final class ManagedIndexSchema ex
           newSchema.registerCopyField(entry.getKey(), destination);
         }
       }
-      //TODO: move this common stuff out to shared methods
-      // Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
       if(persist) {
         success = newSchema.persistManagedSchema(false); // don't just create - update it if it already exists
@@ -813,11 +788,7 @@ public final class ManagedIndexSchema ex
           newSchema.deleteCopyField(entry.getKey(), destination);
         }
       }
-      //TODO: move this common stuff out to shared methods
-      // Run the callbacks on SchemaAware now that everything else is done
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -960,14 +931,8 @@ public final class ManagedIndexSchema ex
       newSchema.fieldTypes.put(typeName, fieldType);
     }
 
-    // Run the callbacks on SchemaAware now that everything else is done
-    for (SchemaAware aware : newSchema.schemaAware)
-      aware.inform(newSchema);
+    newSchema.postReadInform();
     
-    // looks good for the add, notify ResoureLoaderAware objects
-    for (FieldType fieldType : fieldTypeList)
-      informResourceLoaderAwareObjectsForFieldType(fieldType);
-
     newSchema.refreshAnalyzers();
 
     if (persist) {
@@ -1018,12 +983,7 @@ public final class ManagedIndexSchema ex
       for (String name : names) {
         newSchema.fieldTypes.remove(name);
       }
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
-      for (FieldType fieldType : newSchema.fieldTypes.values()) {
-        informResourceLoaderAwareObjectsForFieldType(fieldType);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -1153,12 +1113,7 @@ public final class ManagedIndexSchema ex
       }
       newSchema.rebuildCopyFields(copyFieldsToRebuild);
 
-      for (SchemaAware aware : newSchema.schemaAware) {
-        aware.inform(newSchema);
-      }
-      for (FieldType fieldType : newSchema.fieldTypes.values()) {
-        newSchema.informResourceLoaderAwareObjectsForFieldType(fieldType);
-      }
+      newSchema.postReadInform();
       newSchema.refreshAnalyzers();
     } else {
       String msg = "This ManagedIndexSchema is not mutable.";
@@ -1167,6 +1122,14 @@ public final class ManagedIndexSchema ex
     }
     return newSchema;
   }
+  
+  @Override
+  protected void postReadInform() {
+    super.postReadInform();
+    for (FieldType fieldType : fieldTypes.values()) {
+      informResourceLoaderAwareObjectsForFieldType(fieldType);
+    }
+  }
 
   /**
    * Informs analyzers used by a fieldType.

Modified: lucene/dev/branches/branch_5x/solr/example/exampledocs/ipod_other.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/example/exampledocs/ipod_other.xml?rev=1672239&r1=1672238&r2=1672239&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/example/exampledocs/ipod_other.xml (original)
+++ lucene/dev/branches/branch_5x/solr/example/exampledocs/ipod_other.xml Thu Apr  9 04:46:21 2015
@@ -44,7 +44,7 @@
   <field name="cat">electronics</field>
   <field name="cat">connector</field>
   <field name="features">car power adapter for iPod, white</field>
-  <field name="weight">2</field>
+  <field name="weight">2.0</field>
   <field name="price">11.50</field>
   <field name="popularity">1</field>
   <field name="inStock">false</field>