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

garydgregory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-xml.git

commit 641d267d7f403806a89a765be466ccdb36249c74
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Aug 26 08:18:32 2026 -0400

    Fail-fast in constructor on null delegate input.
    
    - As already done in some delegating classes.
    - Javadoc
    - "impl" -> "implementation"
---
 .../commons/xml/HardeningDocumentBuilder.java      |  9 +++++++-
 .../xml/HardeningDocumentBuilderFactory.java       | 10 +++++++-
 .../org/apache/commons/xml/HardeningSAXParser.java | 10 +++++++-
 .../commons/xml/HardeningSAXParserFactory.java     | 10 +++++++-
 .../org/apache/commons/xml/HardeningSchema.java    | 16 +++++++++----
 .../apache/commons/xml/HardeningSchemaFactory.java | 10 +++++++-
 .../org/apache/commons/xml/HardeningTemplates.java | 27 ++++++++++++++++------
 .../commons/xml/HardeningTemplatesHandler.java     | 19 ++++++++++++---
 .../apache/commons/xml/HardeningTransformer.java   | 27 +++++++++++++++-------
 .../commons/xml/HardeningTransformerFactory.java   | 24 ++++++++++++++++---
 .../commons/xml/HardeningTransformerHandler.java   | 15 ++++++++++--
 .../org/apache/commons/xml/HardeningValidator.java |  9 +++++++-
 .../commons/xml/HardeningValidatorHandler.java     | 10 +++++++-
 .../org/apache/commons/xml/HardeningXMLFilter.java |  9 +++++++-
 .../commons/xml/HardeningXMLInputFactory.java      |  9 +++++++-
 .../org/apache/commons/xml/HardeningXMLReader.java |  9 +++++++-
 .../org/apache/commons/xml/HardeningXPath.java     |  6 +++++
 .../commons/xml/HardeningXPathExpression.java      | 10 +++++++-
 .../apache/commons/xml/HardeningXPathFactory.java  |  6 +++++
 .../apache/commons/xml/TransformerHardener.java    |  2 +-
 20 files changed, 208 insertions(+), 39 deletions(-)

diff --git a/src/main/java/org/apache/commons/xml/HardeningDocumentBuilder.java 
b/src/main/java/org/apache/commons/xml/HardeningDocumentBuilder.java
index 93cbdb8..7c85944 100644
--- a/src/main/java/org/apache/commons/xml/HardeningDocumentBuilder.java
+++ b/src/main/java/org/apache/commons/xml/HardeningDocumentBuilder.java
@@ -18,6 +18,7 @@
 package org.apache.commons.xml;
 
 import java.io.IOException;
+import java.util.Objects;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.validation.Schema;
@@ -42,8 +43,14 @@ final class HardeningDocumentBuilder extends DocumentBuilder 
{
 
     private final FallbackIgnoreEntityResolver2 floor = new 
FallbackIgnoreEntityResolver2(null);
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningDocumentBuilder(final DocumentBuilder delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         delegate.setEntityResolver(floor);
     }
 
diff --git 
a/src/main/java/org/apache/commons/xml/HardeningDocumentBuilderFactory.java 
b/src/main/java/org/apache/commons/xml/HardeningDocumentBuilderFactory.java
index 59c066e..19a6ec3 100644
--- a/src/main/java/org/apache/commons/xml/HardeningDocumentBuilderFactory.java
+++ b/src/main/java/org/apache/commons/xml/HardeningDocumentBuilderFactory.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -35,8 +37,14 @@ final class HardeningDocumentBuilderFactory extends 
DocumentBuilderFactory {
 
     private final DocumentBuilderFactory delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningDocumentBuilderFactory(final DocumentBuilderFactory delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/xml/HardeningSAXParser.java 
b/src/main/java/org/apache/commons/xml/HardeningSAXParser.java
index 9fb396a..8abdc8a 100644
--- a/src/main/java/org/apache/commons/xml/HardeningSAXParser.java
+++ b/src/main/java/org/apache/commons/xml/HardeningSAXParser.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.parsers.SAXParser;
 import javax.xml.validation.Schema;
 
@@ -45,8 +47,14 @@ final class HardeningSAXParser extends SAXParser {
     private XMLReader hardenedReader;
     private Parser hardenedParser;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningSAXParser(final SAXParser delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
 
     @Override
diff --git 
a/src/main/java/org/apache/commons/xml/HardeningSAXParserFactory.java 
b/src/main/java/org/apache/commons/xml/HardeningSAXParserFactory.java
index f1fff11..0454f15 100644
--- a/src/main/java/org/apache/commons/xml/HardeningSAXParserFactory.java
+++ b/src/main/java/org/apache/commons/xml/HardeningSAXParserFactory.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
@@ -38,8 +40,14 @@ final class HardeningSAXParserFactory extends 
SAXParserFactory {
 
     private final SAXParserFactory delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningSAXParserFactory(final SAXParserFactory delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/xml/HardeningSchema.java 
b/src/main/java/org/apache/commons/xml/HardeningSchema.java
index f3294c1..fe2166d 100644
--- a/src/main/java/org/apache/commons/xml/HardeningSchema.java
+++ b/src/main/java/org/apache/commons/xml/HardeningSchema.java
@@ -17,22 +17,30 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.validation.Schema;
 import javax.xml.validation.Validator;
 import javax.xml.validation.ValidatorHandler;
 
 /**
  * {@link Schema} wrapper that hardens every {@link Validator} and {@link 
ValidatorHandler} the inner Schema produces: each {@link Validator} is wrapped 
in
- * {@link HardeningValidator} (which rewrites the Source through {@link 
SAXParserHardener#hardenSource(javax.xml.transform.Source)} and installs the 
resolver floor), and
- * each {@link ValidatorHandler} is wrapped in a {@link 
HardeningValidatorHandler} that keeps the same ignore-all resolver floor so 
{@code xsi:schemaLocation} is
- * not resolved during SAX-driven validation.
+ * {@link HardeningValidator} (which rewrites the Source through {@link 
SAXParserHardener#hardenSource(javax.xml.transform.Source)} and installs the 
resolver
+ * floor), and each {@link ValidatorHandler} is wrapped in a {@link 
HardeningValidatorHandler} that keeps the same ignore-all resolver floor so
+ * {@code xsi:schemaLocation} is not resolved during SAX-driven validation.
  */
 final class HardeningSchema extends Schema {
 
     private final Schema delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningSchema(final Schema delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/xml/HardeningSchemaFactory.java 
b/src/main/java/org/apache/commons/xml/HardeningSchemaFactory.java
index 573b000..c517265 100644
--- a/src/main/java/org/apache/commons/xml/HardeningSchemaFactory.java
+++ b/src/main/java/org/apache/commons/xml/HardeningSchemaFactory.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.validation.Schema;
@@ -69,8 +71,14 @@ private static Source[] harden(final Source[] schemas) 
throws SAXException {
 
     private final FallbackIgnoreLSResourceResolver floor = new 
FallbackIgnoreLSResourceResolver(null);
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningSchemaFactory(final SchemaFactory delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         // Compile-time block for xs:import/include/redefine; the wrappers 
carry the rest (per-product resolver, source rewriting, limits via the reader).
         delegate.setResourceResolver(floor);
     }
diff --git a/src/main/java/org/apache/commons/xml/HardeningTemplates.java 
b/src/main/java/org/apache/commons/xml/HardeningTemplates.java
index 0208c11..7706a49 100644
--- a/src/main/java/org/apache/commons/xml/HardeningTemplates.java
+++ b/src/main/java/org/apache/commons/xml/HardeningTemplates.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
 import java.util.Properties;
 import java.util.function.Supplier;
 
@@ -29,24 +30,37 @@
 /**
  * {@link Templates} wrapper whose only purpose is to return a {@link 
HardeningTransformer} from {@link Templates#newTransformer()}, with the 
factory's
  * compile-time {@link URIResolver} pre-installed.
- *
- * <p>Both Apache Xalan 2.7 and stock-JDK XSLTC fail to propagate the 
factory's URIResolver through {@code Templates.newTransformer()}: the produced 
runtime
+ * <p>
+ * Both Apache Xalan 2.7 and stock-JDK XSLTC fail to propagate the factory's 
URIResolver through {@code Templates.newTransformer()}: the produced runtime
  * Transformer has a null URIResolver unless the caller sets one, leaving 
runtime {@code document()} calls unguarded. Snapshotting the resolver at 
compile time
  * and restoring it onto the runtime Transformer matches the JAXP-conformant 
intuition that the factory's resolver is the default for any Transformer the
- * factory ultimately produces.</p>
+ * factory ultimately produces.
+ * </p>
  */
 final class HardeningTemplates implements Templates {
 
     private final Templates delegate;
 
-    /** Compile-time URIResolver snapshot; the underlying impl does not 
propagate the factory's resolver onto Transformers obtained from Templates. */
+    /**
+     * Compile-time URIResolver snapshot; the underlying implementation does 
not propagate the factory's resolver onto Transformers obtained from Templates.
+     */
     private final URIResolver uriResolver;
 
-    /** Empty-{@link Source} supplier for the produced Transformer's floor; 
{@code null} means the default empty DOM. */
+    /**
+     * Empty-{@link Source} supplier for the produced Transformer's floor; 
{@code null} means the default empty DOM.
+     */
     private final Supplier<Source> emptySource;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate    the delegate to wrap; must not be {@code null}.
+     * @param uriResolver the compile-time URIResolver snapshot to restore 
onto Transformers produced from the compiled Templates; may be {@code null}.
+     * @param emptySource the empty-{@link Source} supplier for the produced 
Transformers
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningTemplates(final Templates delegate, final URIResolver 
uriResolver, final Supplier<Source> emptySource) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         this.uriResolver = uriResolver;
         this.emptySource = emptySource;
     }
@@ -65,7 +79,6 @@ public Properties getOutputProperties() {
         return delegate.getOutputProperties();
     }
 
-
     @Override
     public Transformer newTransformer() throws 
TransformerConfigurationException {
         final Transformer transformer = delegate.newTransformer();
diff --git 
a/src/main/java/org/apache/commons/xml/HardeningTemplatesHandler.java 
b/src/main/java/org/apache/commons/xml/HardeningTemplatesHandler.java
index 04124a7..219fcab 100644
--- a/src/main/java/org/apache/commons/xml/HardeningTemplatesHandler.java
+++ b/src/main/java/org/apache/commons/xml/HardeningTemplatesHandler.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
 import java.util.function.Supplier;
 
 import javax.xml.transform.Source;
@@ -40,14 +41,26 @@ final class HardeningTemplatesHandler implements 
TemplatesHandler {
 
     private final TemplatesHandler delegate;
 
-    /** Compile-time URIResolver snapshot, restored onto Transformers produced 
from the compiled Templates. */
+    /**
+     * Compile-time URIResolver snapshot, restored onto Transformers produced 
from the compiled Templates.
+     */
     private final URIResolver uriResolver;
 
-    /** Empty-{@link Source} supplier for the produced Templates' floor; 
{@code null} means the default empty DOM. */
+    /**
+     * Empty-{@link Source} supplier for the produced Templates' floor; {@code 
null} means the default empty DOM.
+     */
     private final Supplier<Source> emptySource;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @param uriResolver the compile-time URIResolver snapshot to restore 
onto Transformers produced from the compiled Templates; may be {@code null}.
+     * @param emptySource the empty-{@link Source} supplier for the produced 
Templates.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningTemplatesHandler(final TemplatesHandler delegate, final 
URIResolver uriResolver, final Supplier<Source> emptySource) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         this.uriResolver = uriResolver;
         this.emptySource = emptySource;
     }
diff --git a/src/main/java/org/apache/commons/xml/HardeningTransformer.java 
b/src/main/java/org/apache/commons/xml/HardeningTransformer.java
index c6b4288..1210f8f 100644
--- a/src/main/java/org/apache/commons/xml/HardeningTransformer.java
+++ b/src/main/java/org/apache/commons/xml/HardeningTransformer.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
 import java.util.Properties;
 import java.util.function.Supplier;
 
@@ -30,24 +31,35 @@
 
 /**
  * {@link Transformer} wrapper that rewrites the Source on every {@link 
Transformer#transform(Source, Result)} call through
- * {@link SAXParserHardener#hardenSource(Source)} before delegating, and keeps 
an ignore-all {@link URIResolver} floor so runtime {@code document()} calls a 
caller does not
- * resolve return empty rather than being fetched.
- *
- * <p>The floor is installed on the delegate transformer at construction, 
seeded with the factory's compile-time resolver; {@link 
#setURIResolver(URIResolver)}
+ * {@link SAXParserHardener#hardenSource(Source)} before delegating, and keeps 
an ignore-all {@link URIResolver} floor so runtime {@code document()} calls a
+ * caller does not resolve return empty rather than being fetched.
+ * <p>
+ * The floor is installed on the delegate transformer at construction, seeded 
with the factory's compile-time resolver; {@link #setURIResolver(URIResolver)}
  * routes a caller's resolver through it rather than replacing it, so the 
block cannot be dropped. {@link #reset()} re-establishes the floor, seeded 
again with
- * the factory's compile-time resolver, matching the just-constructed 
state.</p>
+ * the factory's compile-time resolver, matching the just-constructed state.
+ * </p>
  */
 final class HardeningTransformer extends Transformer {
 
     private final Transformer delegate;
 
-    /** Compile-time URIResolver snapshot the floor is seeded with, both at 
construction and again on {@link #reset()}. */
+    /**
+     * Compile-time URIResolver snapshot the floor is seeded with, both at 
construction and again on {@link #reset()}.
+     */
     private final URIResolver uriResolver;
 
     private final FallbackIgnoreURIResolver floor;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate    the delegate to wrap; must not be {@code null}.
+     * @param uriResolver the compile-time URIResolver snapshot to seed the 
floor with; may be {@code null}.
+     * @param emptySource the empty-{@link Source} supplier for the produced 
Transformers
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningTransformer(final Transformer delegate, final URIResolver 
uriResolver, final Supplier<Source> emptySource) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         this.uriResolver = uriResolver;
         this.floor = new FallbackIgnoreURIResolver(uriResolver, emptySource);
         delegate.setURIResolver(floor);
@@ -110,7 +122,6 @@ public void setParameter(final String name, final Object 
value) {
         delegate.setParameter(name, value);
     }
 
-
     @Override
     public void setURIResolver(final URIResolver resolver) {
         floor.setDelegate(resolver);
diff --git 
a/src/main/java/org/apache/commons/xml/HardeningTransformerFactory.java 
b/src/main/java/org/apache/commons/xml/HardeningTransformerFactory.java
index 4aa0d37..5dd22c3 100644
--- a/src/main/java/org/apache/commons/xml/HardeningTransformerFactory.java
+++ b/src/main/java/org/apache/commons/xml/HardeningTransformerFactory.java
@@ -18,6 +18,7 @@
 package org.apache.commons.xml;
 
 import java.io.IOException;
+import java.util.Objects;
 import java.util.function.Supplier;
 
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -53,7 +54,8 @@
  * <ol>
  *   <li>{@link HardeningTransformerFactory} rewrites the Source on every 
entry point that compiles a stylesheet or transforms a one-shot input.</li>
  *   <li>{@link HardeningTemplates} returns a {@link HardeningTransformer} 
from {@link Templates#newTransformer()} so runtime source parsing is also 
covered, and
- *       restores the factory's URIResolver onto the produced Transformer 
(which the underlying impl typically does not propagate through {@code 
Templates}).</li>
+ *       restores the factory's URIResolver onto the produced Transformer 
(which the underlying implementation typically does not propagate through
+ *       {@code Templates}).</li>
  *   <li>{@link HardeningTransformer} rewrites the Source on every {@link 
Transformer#transform(Source, javax.xml.transform.Result)} call.</li>
  * </ol>
  *
@@ -113,17 +115,33 @@ private static Templates unwrap(final Templates 
templates) {
 
     private final SAXTransformerFactory delegate;
 
-    /** Empty-{@link Source} supplier for the resolver floor, threaded onto 
every produced Templates/Transformer; {@code null} means the default empty DOM. 
*/
+    /**
+     * Empty-{@link Source} supplier for the resolver floor, threaded onto 
every produced Templates/Transformer; {@code null} means the default empty DOM.
+     */
     private final Supplier<Source> emptySource;
 
     private final FallbackIgnoreURIResolver floor;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningTransformerFactory(final SAXTransformerFactory delegate) {
         this(delegate, null);
     }
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate    the delegate to wrap; must not be {@code null}.
+     * @param emptySource the empty-{@link Source} supplier for the resolver 
floor, threaded onto every produced Templates/Transformer; {@code null} means 
the
+     *                    default empty DOM.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningTransformerFactory(final SAXTransformerFactory delegate, final 
Supplier<Source> emptySource) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         this.emptySource = emptySource;
         this.floor = new FallbackIgnoreURIResolver(null, emptySource);
         // Compile-time block for xsl:import/xsl:include and document(); a 
caller-set resolver is routed through the floor rather than replacing it.
diff --git 
a/src/main/java/org/apache/commons/xml/HardeningTransformerHandler.java 
b/src/main/java/org/apache/commons/xml/HardeningTransformerHandler.java
index 1b0f5b1..69000e9 100644
--- a/src/main/java/org/apache/commons/xml/HardeningTransformerHandler.java
+++ b/src/main/java/org/apache/commons/xml/HardeningTransformerHandler.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
 import java.util.function.Supplier;
 
 import javax.xml.transform.Result;
@@ -42,11 +43,21 @@ final class HardeningTransformerHandler implements 
TransformerHandler {
 
     private final TransformerHandler delegate;
 
-    /** Wraps the handler's LIVE transformer; constructing it installs the 
resolver floor that the handler's own transform then runs under. */
+    /**
+     * Wraps the handler's LIVE transformer; constructing it installs the 
resolver floor that the handler's own transform then runs under.
+     */
     private final HardeningTransformer transformer;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @param uriResolver the compile-time URIResolver snapshot to restore 
onto the live transformer; may be {@code null}.
+     * @param emptySource the empty-{@link Source} supplier for the produced 
Transformer's floor; {@code null} means the default empty DOM.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningTransformerHandler(final TransformerHandler delegate, final 
URIResolver uriResolver, final Supplier<Source> emptySource) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         this.transformer = new HardeningTransformer(delegate.getTransformer(), 
uriResolver, emptySource);
     }
 
diff --git a/src/main/java/org/apache/commons/xml/HardeningValidator.java 
b/src/main/java/org/apache/commons/xml/HardeningValidator.java
index 730230f..96d651b 100644
--- a/src/main/java/org/apache/commons/xml/HardeningValidator.java
+++ b/src/main/java/org/apache/commons/xml/HardeningValidator.java
@@ -18,6 +18,7 @@
 package org.apache.commons.xml;
 
 import java.io.IOException;
+import java.util.Objects;
 
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
@@ -41,8 +42,14 @@ final class HardeningValidator extends Validator {
 
     private final FallbackIgnoreLSResourceResolver floor = new 
FallbackIgnoreLSResourceResolver(null);
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningValidator(final Validator delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         // Block xsi:schemaLocation resolution; neither the JDK nor Xerces 
reliably propagates the factory's resolver to its Validators. The floor is a
         // non-removable lower bound: a caller opts specific lookups in by 
setting their own resolver, but cannot drop the ignore-all block.
         delegate.setResourceResolver(floor);
diff --git 
a/src/main/java/org/apache/commons/xml/HardeningValidatorHandler.java 
b/src/main/java/org/apache/commons/xml/HardeningValidatorHandler.java
index 2cc80b7..5961b6e 100644
--- a/src/main/java/org/apache/commons/xml/HardeningValidatorHandler.java
+++ b/src/main/java/org/apache/commons/xml/HardeningValidatorHandler.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.validation.TypeInfoProvider;
 import javax.xml.validation.ValidatorHandler;
 
@@ -41,8 +43,14 @@ final class HardeningValidatorHandler extends 
ValidatorHandler {
 
     private final FallbackIgnoreLSResourceResolver floor = new 
FallbackIgnoreLSResourceResolver(null);
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningValidatorHandler(final ValidatorHandler delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         delegate.setResourceResolver(floor);
     }
 
diff --git a/src/main/java/org/apache/commons/xml/HardeningXMLFilter.java 
b/src/main/java/org/apache/commons/xml/HardeningXMLFilter.java
index eac2f13..05de4f7 100644
--- a/src/main/java/org/apache/commons/xml/HardeningXMLFilter.java
+++ b/src/main/java/org/apache/commons/xml/HardeningXMLFilter.java
@@ -18,6 +18,7 @@
 package org.apache.commons.xml;
 
 import java.io.IOException;
+import java.util.Objects;
 
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
@@ -44,8 +45,14 @@ final class HardeningXMLFilter extends XMLFilterImpl {
 
     private final HardeningTemplates templates;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param templates the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningXMLFilter(final HardeningTemplates templates) {
-        this.templates = templates;
+        this.templates = Objects.requireNonNull(templates, "templates");
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/xml/HardeningXMLInputFactory.java 
b/src/main/java/org/apache/commons/xml/HardeningXMLInputFactory.java
index ecdc2e4..a0635b6 100644
--- a/src/main/java/org/apache/commons/xml/HardeningXMLInputFactory.java
+++ b/src/main/java/org/apache/commons/xml/HardeningXMLInputFactory.java
@@ -19,6 +19,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.util.Objects;
 
 import javax.xml.stream.EventFilter;
 import javax.xml.stream.StreamFilter;
@@ -64,8 +65,14 @@ private static XMLResolver unwrap(final XMLResolver 
resolver) {
 
     private final XMLInputFactory delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningXMLInputFactory(final XMLInputFactory delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         delegate.setXMLResolver(new FallbackIgnoreXMLResolver(null));
     }
 
diff --git a/src/main/java/org/apache/commons/xml/HardeningXMLReader.java 
b/src/main/java/org/apache/commons/xml/HardeningXMLReader.java
index 61d2b35..856aa67 100644
--- a/src/main/java/org/apache/commons/xml/HardeningXMLReader.java
+++ b/src/main/java/org/apache/commons/xml/HardeningXMLReader.java
@@ -18,6 +18,7 @@
 package org.apache.commons.xml;
 
 import java.io.IOException;
+import java.util.Objects;
 
 import org.xml.sax.ContentHandler;
 import org.xml.sax.DTDHandler;
@@ -45,8 +46,14 @@ class HardeningXMLReader implements XMLReader {
 
     private final FallbackIgnoreEntityResolver2 floor;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningXMLReader(final XMLReader delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
         this.floor = new FallbackIgnoreEntityResolver2(null);
         delegate.setEntityResolver(floor);
     }
diff --git a/src/main/java/org/apache/commons/xml/HardeningXPath.java 
b/src/main/java/org/apache/commons/xml/HardeningXPath.java
index 13cef3a..80eddf6 100644
--- a/src/main/java/org/apache/commons/xml/HardeningXPath.java
+++ b/src/main/java/org/apache/commons/xml/HardeningXPath.java
@@ -73,6 +73,12 @@ static Document parse(final InputSource source) throws 
XPathExpressionException
 
     private final XPath delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningXPath(final XPath delegate) {
         this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
diff --git a/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java 
b/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java
index 7a1446f..15de2bd 100644
--- a/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java
+++ b/src/main/java/org/apache/commons/xml/HardeningXPathExpression.java
@@ -17,6 +17,8 @@
 
 package org.apache.commons.xml;
 
+import java.util.Objects;
+
 import javax.xml.namespace.QName;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathExpressionException;
@@ -34,8 +36,14 @@ final class HardeningXPathExpression implements 
XPathExpression {
 
     private final XPathExpression delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningXPathExpression(final XPathExpression delegate) {
-        this.delegate = delegate;
+        this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java 
b/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java
index a697032..6668057 100644
--- a/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java
+++ b/src/main/java/org/apache/commons/xml/HardeningXPathFactory.java
@@ -36,6 +36,12 @@ final class HardeningXPathFactory extends XPathFactory {
 
     private final XPathFactory delegate;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param delegate the delegate to wrap; must not be {@code null}.
+     * @throws NullPointerException if {@code delegate} is {@code null}.
+     */
     HardeningXPathFactory(final XPathFactory delegate) {
         this.delegate = Objects.requireNonNull(delegate, "delegate");
     }
diff --git a/src/main/java/org/apache/commons/xml/TransformerHardener.java 
b/src/main/java/org/apache/commons/xml/TransformerHardener.java
index 6dbb623..5b937b5 100644
--- a/src/main/java/org/apache/commons/xml/TransformerHardener.java
+++ b/src/main/java/org/apache/commons/xml/TransformerHardener.java
@@ -51,7 +51,7 @@ static TransformerFactory harden(final TransformerFactory 
factory) {
         setFeature(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true);
         if (SaxonProvider.isSaxon(factory.getClass())) {
             // Saxon keeps its vendor Configuration for the channels JAXP 
cannot close,
-            // then goes through the same wrapper as every other impl for the 
URIResolver floor;
+            // then goes through the same wrapper as every other 
implementation for the URIResolver floor;
             // EmptySource is the empty-source shape Saxon's consumers expect.
             return new HardeningTransformerFactory((SAXTransformerFactory) 
SaxonProvider.configure(factory), SaxonProvider.emptySourceSupplier());
         }

Reply via email to