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:28 UTC

[commons-jxpath] branch master updated (c05ba07 -> 9add3bb)

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

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


    from c05ba07  ValueUtils.setValue() now throws IllegalArgumentException instead of RuntimeException.
     new 28b0187  ClassLoaderUtil.toCanonicalName() now calls Objects.requireNonNull() instead of throwing a RuntimeException
     new 9add3bb  XMLDocumentContainer.XMLDocumentContainer(Source) now calls Objects.requireNonNull() instead of throwing a RuntimeException.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                                           | 6 ++++++
 src/main/java/org/apache/commons/jxpath/XMLDocumentContainer.java | 6 ++----
 src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java | 7 +++----
 3 files changed, 11 insertions(+), 8 deletions(-)


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

Posted by gg...@apache.org.
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 28b01872c8c092dee304c3588786338e3e4bdb9a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 23 10:02:20 2023 -0400

    ClassLoaderUtil.toCanonicalName() now calls Objects.requireNonNull()
    instead of throwing a RuntimeException
    
    Also make the exception message less Engligh-centric
---
 src/changes/changes.xml                                           | 3 +++
 src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java | 7 +++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6f07cb8..9d6560d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -92,6 +92,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         ValueUtils.setValue() now throws IllegalArgumentException instead of RuntimeException.
       </action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">
+        ClassLoaderUtil.toCanonicalName() 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/util/ClassLoaderUtil.java b/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java
index 1994b53..eb6eabc 100644
--- a/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java
+++ b/src/main/java/org/apache/commons/jxpath/util/ClassLoaderUtil.java
@@ -18,6 +18,7 @@ package org.apache.commons.jxpath.util;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Port of class loading methods from <code>org.apache.commons.lang3.ClassUtils</code> from
@@ -145,10 +146,8 @@ public class ClassLoaderUtil {
      * @return the converted name
      */
     private static String toCanonicalName(String className) {
-        if (className == null) {
-            throw new RuntimeException("Argument className was null.");
-        }
-        else if (className.endsWith("[]")) {
+        Objects.requireNonNull(className, "className");
+        if (className.endsWith("[]")) {
             final StringBuilder classNameBuffer = new StringBuilder();
             while (className.endsWith("[]")) {
                 className = className.substring(0, className.length() - 2);


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

Posted by gg...@apache.org.
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);
     }
 
     /**