You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/23 14:20:30 UTC

[commons-jxpath] 02/02: XMLDocumentContainer.XMLDocumentContainer(Source) now calls Objects.requireNonNull() instead of throwing a RuntimeException.

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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jxpath.git

commit 9add3bbe61cf33ebd1bc8fd073014add1a37f5b7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 23 10:20:24 2023 -0400

    XMLDocumentContainer.XMLDocumentContainer(Source) now calls
    Objects.requireNonNull() instead of throwing a RuntimeException.
---
 src/changes/changes.xml                                           | 3 +++
 src/main/java/org/apache/commons/jxpath/XMLDocumentContainer.java | 6 ++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9d6560d..edb1e27 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -95,6 +95,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         ClassLoaderUtil.toCanonicalName() now calls Objects.requireNonNull() instead of throwing a RuntimeException.
       </action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">
+        XMLDocumentContainer.XMLDocumentContainer(Source) now calls Objects.requireNonNull() instead of throwing a RuntimeException.
+      </action>
       <!-- ADD -->
       <action issue="JXPATH-123" dev="mbenson" type="add">
         XPath function "ends-with" is not implemented (although "starts-with" is).
diff --git a/src/main/java/org/apache/commons/jxpath/XMLDocumentContainer.java b/src/main/java/org/apache/commons/jxpath/XMLDocumentContainer.java
index 6ca3758..0079d72 100644
--- a/src/main/java/org/apache/commons/jxpath/XMLDocumentContainer.java
+++ b/src/main/java/org/apache/commons/jxpath/XMLDocumentContainer.java
@@ -17,6 +17,7 @@
 package org.apache.commons.jxpath;
 
 import java.net.URL;
+import java.util.Objects;
 
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
@@ -61,10 +62,7 @@ public class XMLDocumentContainer implements Container {
      * @param source XML source
      */
     public XMLDocumentContainer(final Source source) {
-        this.source = source;
-        if (source == null) {
-            throw new RuntimeException("Source is null");
-        }
+        this.source = Objects.requireNonNull(source);
     }
 
     /**