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 2020/09/07 00:43:28 UTC
[lucene-solr] branch jira/solr14827 updated: bug fix
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch jira/solr14827
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/jira/solr14827 by this push:
new 6e024d1 bug fix
6e024d1 is described below
commit 6e024d1f312940ad0f26bd22b25d3dee6d9326e0
Author: noblepaul <no...@gmail.com>
AuthorDate: Mon Sep 7 10:43:03 2020 +1000
bug fix
---
.../java/org/apache/solr/core/XmlConfigFile.java | 26 ++++------------------
.../java/org/apache/solr/schema/IndexSchema.java | 12 ++++++----
2 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
index 08fe569..ad6213d 100644
--- a/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
+++ b/solr/core/src/java/org/apache/solr/core/XmlConfigFile.java
@@ -20,11 +20,6 @@ import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
@@ -108,8 +103,7 @@ public class XmlConfigFile { // formerly simply "Config"
* @param prefix an optional prefix that will be prepended to all non-absolute xpath expressions
* @param substituteProps optional property substitution
*/
- public XmlConfigFile(SolrResourceLoader loader, String name, InputSource is, String prefix, Properties substituteProps) throws ParserConfigurationException, IOException, SAXException
- {
+ public XmlConfigFile(SolrResourceLoader loader, String name, InputSource is, String prefix, Properties substituteProps) throws IOException {
if( loader == null ) {
loader = new SolrResourceLoader(SolrPaths.locateSolrHome());
}
@@ -145,7 +139,7 @@ public class XmlConfigFile { // formerly simply "Config"
db.setErrorHandler(xmllog);
try {
doc = db.parse(is);
- origDoc = copyDoc(doc);
+ origDoc = doc;
} finally {
// some XML parsers are broken and don't close the byte stream (but they should according to spec)
IOUtils.closeQuietly(is.getByteStream());
@@ -153,7 +147,7 @@ public class XmlConfigFile { // formerly simply "Config"
if (substituteProps != null) {
DOMUtil.substituteProperties(doc, getSubstituteProperties());
}
- } catch (ParserConfigurationException | SAXException | TransformerException e) {
+ } catch (ParserConfigurationException | SAXException e) {
SolrException.log(log, "Exception during parsing file: " + name, e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
@@ -179,15 +173,7 @@ public class XmlConfigFile { // formerly simply "Config"
return this.substituteProperties;
}
- private static Document copyDoc(Document doc) throws TransformerException {
- TransformerFactory tfactory = TransformerFactory.newInstance();
- Transformer tx = tfactory.newTransformer();
- DOMSource source = new DOMSource(doc);
- DOMResult result = new DOMResult();
- tx.transform(source, result);
- return (Document) result.getNode();
- }
-
+
/**
* @since solr 1.3
*/
@@ -237,10 +223,6 @@ public class XmlConfigFile { // formerly simply "Config"
return getNode(path, doc, errifMissing);
}
- public Node getUnsubstitutedNode(String path, boolean errIfMissing) {
- return getNode(path, origDoc, errIfMissing);
- }
-
public Node getNode(String path, Document doc, boolean errIfMissing) {
XPath xpath = xpathFactory.newXPath();
String xstr = normalize(path);
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 7b13349..53d3a80 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -55,6 +55,7 @@ import org.apache.solr.common.MapSerializable;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.cloud.SolrClassLoader;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -63,7 +64,6 @@ import org.apache.solr.common.util.Cache;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.Pair;
import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.common.cloud.SolrClassLoader;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.core.XmlConfigFile;
@@ -755,9 +755,13 @@ public class IndexSchema {
// NodeList nodes = (NodeList)xpath.evaluate(expression, document, XPathConstants.NODESET);
List<ConfigNode> nodes = n.children(COPY_FIELD);
- for (int i=0; i<nodes.size(); i++) {
- ConfigNode node = nodes.get(i);
-// NamedNodeMap attrs = node.getAttributes();
+ ConfigNode f = n.child(FIELDS);
+ if (f != null) {
+ List<ConfigNode> c = f.children(COPY_FIELD);
+ if (nodes.isEmpty()) nodes = c;
+ else nodes.addAll(c);
+ }
+ for (ConfigNode node : nodes) {
String source = DOMUtil.getAttr(node, SOURCE, COPY_FIELD + " definition");
String dest = DOMUtil.getAttr(node, DESTINATION, COPY_FIELD + " definition");