diff --git a/geowebcache/core/pom.xml b/geowebcache/core/pom.xml
index d309d9b99..05cf22068 100644
--- a/geowebcache/core/pom.xml
+++ b/geowebcache/core/pom.xml
@@ -23,6 +23,10 @@
org.geotools
gt-coverage
+
+ org.geotools
+ gt-xml
+
org.apache.commons
commons-collections4
diff --git a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java
index 7c330fb78..6e0cb24cf 100644
--- a/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java
+++ b/geowebcache/core/src/main/java/org/geowebcache/config/XMLConfiguration.java
@@ -45,7 +45,6 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
@@ -54,6 +53,7 @@
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.geotools.util.logging.Logging;
+import org.geotools.xml.XMLUtils;
import org.geowebcache.GeoWebCacheEnvironment;
import org.geowebcache.GeoWebCacheException;
import org.geowebcache.GeoWebCacheExtensions;
@@ -616,7 +616,7 @@ static Node loadDocument(InputStream xmlFile) throws ConfigurationException, IOE
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
- DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ DocumentBuilder docBuilder = XMLUtils.newDocumentBuilder(docBuilderFactory);
topNode = checkAndTransform(docBuilder.parse(xmlFile));
} catch (Exception e) {
throw (IOException) new IOException(e.getMessage()).initCause(e);
@@ -758,7 +758,7 @@ static String getCurrentSchemaVersion() {
Document dom;
try (InputStream is = XMLConfiguration.class.getResourceAsStream("geowebcache.xsd")) {
- dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
+ dom = XMLUtils.newDocumentBuilder().parse(is);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -777,7 +777,7 @@ private static Node applyTransform(Node oldRootNode, String xslFilename) {
try (InputStream is = XMLConfiguration.class.getResourceAsStream(xslFilename)) {
try {
- transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(is));
+ transformer = XMLUtils.newTransformer(new StreamSource(is));
transformer.transform(new DOMSource(oldRootNode), result);
} catch (TransformerFactoryConfigurationError | TransformerException e) {
log.log(Level.FINE, e.getMessage(), e);
diff --git a/geowebcache/pmd-ruleset.xml b/geowebcache/pmd-ruleset.xml
index 4031bf176..78b495ef7 100644
--- a/geowebcache/pmd-ruleset.xml
+++ b/geowebcache/pmd-ruleset.xml
@@ -114,5 +114,140 @@ GeoWebCache ruleset. See https://pmd.github.io/pmd/pmd_userdocs_making_rulesets.
-
+
+
+
+
+ Notice use of DocumentBuilderFactory.newInstance() which should be avoided in favor of
+ XMLUtils.DocumentBuilderFactory(Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ Notice use of DocumentBuilderFactory.newDocumentBuilder() which should be avoided in favor of
+ XMLUtils.newDocumentBuilder(Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ Notice use of TransformerFactory.newInstance() which should be avoided in favor of
+ XMLUtils.newTransformerFactory(Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ Notice use of TransformerFactory.newTransformer() which should be avoided in favor of
+ XMLUtils.newTransformer(Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ Notice use of TransformerFactory.newTransformer(Source) which should be avoided in favor of
+ XMLUtils.newTransformer(Source,Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ Notice use of SAXParserFactory.newInstance() which should be avoided in favor of
+ XMLUtils.newSAXParserFactory(Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+ Notice use of SAXParserFactory.newSAXParser() which should be avoided in favor of
+ XMLUtils.newSAXParser(Hints) to respect GeoTools init configuration.
+
+ 3
+
+
+
+
+
+
+
+
+