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


The following commit(s) were added to refs/heads/main by this push:
     new 0ccf1c8  It's always a feature, simplify.
0ccf1c8 is described below

commit 0ccf1c8226257a8c2aace5b28b955d5ae70c917f
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Aug 28 15:22:38 2026 -0400

    It's always a feature, simplify.
---
 .../commons/xml/SecureDocumentBuilderFactory.java  |  2 +-
 .../org/apache/commons/xml/SecureException.java    | 25 +++++++++++-----------
 .../apache/commons/xml/SecureSAXParserFactory.java |  4 ++--
 .../commons/xml/SecureTransformerFactory.java      |  2 +-
 .../org/apache/commons/xml/SecureXPathFactory.java |  2 +-
 5 files changed, 17 insertions(+), 18 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/xml/SecureDocumentBuilderFactory.java 
b/src/main/java/org/apache/commons/xml/SecureDocumentBuilderFactory.java
index c4719a8..7b4d65f 100644
--- a/src/main/java/org/apache/commons/xml/SecureDocumentBuilderFactory.java
+++ b/src/main/java/org/apache/commons/xml/SecureDocumentBuilderFactory.java
@@ -353,7 +353,7 @@ private static void setFeature(final DocumentBuilderFactory 
factory, final Strin
         try {
             factory.setFeature(feature, value);
         } catch (final ParserConfigurationException e) {
-            throw SecureException.settingFailed("feature", feature, factory, 
e);
+            throw SecureException.featureFailed(feature, factory, e);
         }
     }
 
diff --git a/src/main/java/org/apache/commons/xml/SecureException.java 
b/src/main/java/org/apache/commons/xml/SecureException.java
index a82ae55..fe4848e 100644
--- a/src/main/java/org/apache/commons/xml/SecureException.java
+++ b/src/main/java/org/apache/commons/xml/SecureException.java
@@ -44,6 +44,18 @@ final class SecureException extends IllegalStateException {
      */
     static final String THROW_ON_UNRESOLVED = 
"org.apache.commons.xml.throwOnUnresolved";
 
+    /**
+     * Builds the standard exception for a rejected secure setting.
+     * @param name   the name of the feature, attribute or property that could 
not be set.
+     * @param target the factory, parser, validator or reader that rejected 
the setting; its concrete class names the offending implementation.
+     * @param cause  the original checked or unchecked exception from the JAXP 
implementation.
+     *
+     * @return the exception to throw.
+     */
+    static SecureException featureFailed(final String name, final Object 
target, final Throwable cause) {
+        return new SecureException("Failed to set feature '" + name + "' on " 
+ target.getClass().getName(), cause);
+    }
+
     /**
      * Builds the standard "forbidden" message shared by every resolver floor 
when {@link #throwOnUnresolved()} rejects an unresolved reference.
      *
@@ -59,19 +71,6 @@ static String forbidden(final String type, final String 
namespace, final String
                 SecureException.THROW_ON_UNRESOLVED, type, namespace, 
publicId, systemId, baseURI);
     }
 
-    /**
-     * Builds the standard exception for a rejected secure setting.
-     *
-     * @param kind   the kind of setting: {@code "feature"}, {@code 
"attribute"} or {@code "property"}.
-     * @param name   the name of the feature, attribute or property that could 
not be set.
-     * @param target the factory, parser, validator or reader that rejected 
the setting; its concrete class names the offending implementation.
-     * @param cause  the original checked or unchecked exception from the JAXP 
implementation.
-     * @return the exception to throw.
-     */
-    static SecureException settingFailed(final String kind, final String name, 
final Object target, final Throwable cause) {
-        return new SecureException("Failed to set " + kind + " '" + name + "' 
on " + target.getClass().getName(), cause);
-    }
-
     /**
      * Whether unresolved external references must be rejected instead of 
resolved to empty content.
      *
diff --git a/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java 
b/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java
index 52d8256..7873404 100644
--- a/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java
+++ b/src/main/java/org/apache/commons/xml/SecureSAXParserFactory.java
@@ -397,7 +397,7 @@ private static void setFeature(final SAXParserFactory 
factory, final String feat
         try {
             factory.setFeature(feature, value);
         } catch (final Exception e) {
-            throw SecureException.settingFailed("feature", feature, factory, 
e);
+            throw SecureException.featureFailed(feature, factory, e);
         }
     }
 
@@ -405,7 +405,7 @@ private static void setFeature(final XMLReader reader, 
final String feature, fin
         try {
             reader.setFeature(feature, value);
         } catch (final Exception e) {
-            throw SecureException.settingFailed("feature", feature, reader, e);
+            throw SecureException.featureFailed(feature, reader, e);
         }
     }
 
diff --git a/src/main/java/org/apache/commons/xml/SecureTransformerFactory.java 
b/src/main/java/org/apache/commons/xml/SecureTransformerFactory.java
index 9079f0b..7033e74 100644
--- a/src/main/java/org/apache/commons/xml/SecureTransformerFactory.java
+++ b/src/main/java/org/apache/commons/xml/SecureTransformerFactory.java
@@ -448,7 +448,7 @@ private static void setFeature(final TransformerFactory 
factory, final String fe
         try {
             factory.setFeature(feature, value);
         } catch (final Exception e) {
-            throw SecureException.settingFailed("feature", feature, factory, 
e);
+            throw SecureException.featureFailed(feature, factory, e);
         }
     }
 
diff --git a/src/main/java/org/apache/commons/xml/SecureXPathFactory.java 
b/src/main/java/org/apache/commons/xml/SecureXPathFactory.java
index ff16db4..d7f9378 100644
--- a/src/main/java/org/apache/commons/xml/SecureXPathFactory.java
+++ b/src/main/java/org/apache/commons/xml/SecureXPathFactory.java
@@ -239,7 +239,7 @@ private static void setFeature(final XPathFactory factory, 
final String feature,
         try {
             factory.setFeature(feature, value);
         } catch (final XPathFactoryConfigurationException e) {
-            throw SecureException.settingFailed("feature", feature, factory, 
e);
+            throw SecureException.featureFailed(feature, factory, e);
         }
     }
 

Reply via email to