Skip to content

Apache Lucene open-source search software

Remove unused method which does unsafe XML parsing (#15234)

Uwe Schindler79cb40f6adae
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a1f352a5484..2e17ef96051 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -131,6 +131,9 @@ API Changes
IDs at once, in particular by taking advantage of the new
NumericDocValues#longValues API. (Adrien Grand)
+* GITHUB#15234: Remove unused method which does unsafe XML parsing.
+ (Uwe Schindler, Isaac David)
+
New Features
---------------------
* GITHUB#14565: Add ParentsChildrenBlockJoinQuery that supports parent and child filter in the same query
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java
index 2ce342e17d8..cf5117bc8d9 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/DOMUtils.java
@@ -16,17 +16,18 @@
*/
package org.apache.lucene.queryparser.xml;
-import java.io.Reader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-/** Helper methods for parsing XML */
+/**
+ * Helper methods for parsing XML.
+ *
+ * @lucene.internal
+ */
public class DOMUtils {
+ private DOMUtils() {}
+
public static Element getChildByTagOrFail(Element e, String name) throws ParserException {
Element kid = getChildByTagName(e, name);
if (null == kid) {
@@ -174,32 +175,4 @@ public class DOMUtils {
}
}
}
-
- /**
- * Helper method to parse an XML file into a DOM tree, given a reader.
- *
- * @param is reader of the XML file to be parsed
- * @return an org.w3c.dom.Document object
- */
- public static Document loadXML(Reader is) {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = null;
-
- try {
- db = dbf.newDocumentBuilder();
- } catch (Exception se) {
- throw new RuntimeException("Parser configuration error", se);
- }
-
- // Step 3: parse the input file
- org.w3c.dom.Document doc = null;
- try {
- doc = db.parse(new InputSource(is));
- // doc = db.parse(is);
- } catch (Exception se) {
- throw new RuntimeException("Error parsing file:" + se, se);
- }
-
- return doc;
- }
}