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 2025/03/17 19:23:16 UTC

(commons-jxpath) 03/03: JXPathContextFactoryConfigurationError now reuses its superclass' Throwable cause

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 afeec07e8bc7c5bc511734b51892553eef44cb51
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Mar 17 15:23:09 2025 -0400

    JXPathContextFactoryConfigurationError now reuses its superclass'
    Throwable cause
---
 pom.xml                                            |  3 ++
 src/changes/changes.xml                            |  3 ++
 .../JXPathContextFactoryConfigurationError.java    | 36 +++++-----------------
 .../org/apache/commons/jxpath/JXPathException.java |  2 +-
 4 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8473408..3197300 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,9 @@
             <!-- http://www.jdom.org/docs/apidocs/ is not a secure link -->
             <link>https://javadoc.io/doc/org.jdom/jdom/1.1</link>
           </links>
+          <excludePackageNames>
+            org.apache.commons.jxpath.ri.parser
+          </excludePackageNames>
         </configuration>
       </plugin>
       <plugin>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2c9b0f2..3fe9821 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -117,6 +117,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix" due-to="Gary Gregory">PageScopeContext.getAttributeNames() is now typed with generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">Functions.getUsedNamespaces() is now typed with generics.</action>
       <action dev="ggregory" type="fix" due-to="Gary Gregory">JXPathException now reuses its superclass' Throwable cause.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">Bump JXPathException serialVersionUID from 4306409701468017766L to 2L.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">JXPathContextFactoryConfigurationError now reuses its superclass' Throwable cause.</action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">Bump JXPathContextFactoryConfigurationError serialVersionUID from 1L to 2L.</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/JXPathContextFactoryConfigurationError.java b/src/main/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java
index 22d5a83..4dadc25 100644
--- a/src/main/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java
+++ b/src/main/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java
@@ -23,36 +23,31 @@ package org.apache.commons.jxpath;
  */
 public class JXPathContextFactoryConfigurationError extends Error {
 
-    private static final long serialVersionUID = 1L;
-    /** @serial */
-    private final Exception exception;
+    private static final long serialVersionUID = 2L;
 
     /**
      * Create a new {@code JXPathContextFactoryConfigurationError} with no detail mesage.
      */
     public JXPathContextFactoryConfigurationError() {
-        this.exception = null;
     }
 
     /**
      * Create a new {@code JXPathContextFactoryConfigurationError} with a given {@code Exception} base cause of the error.
      *
-     * @param e The exception to be encapsulated in a JXPathContextFactoryConfigurationError.
+     * @param cause The exception to be encapsulated in a JXPathContextFactoryConfigurationError.
      */
-    public JXPathContextFactoryConfigurationError(final Exception e) {
-        super(e.toString());
-        this.exception = e;
+    public JXPathContextFactoryConfigurationError(final Exception cause) {
+        super(cause);
     }
 
     /**
      * Create a new {@code JXPathContextFactoryConfigurationError} with the given {@code Exception} base cause and detail message.
      *
-     * @param e   The exception to be encapsulated in a JXPathContextFactoryConfigurationError
+     * @param cause   The exception to be encapsulated in a JXPathContextFactoryConfigurationError
      * @param msg The detail message.
      */
-    public JXPathContextFactoryConfigurationError(final Exception e, final String msg) {
-        super(msg);
-        this.exception = e;
+    public JXPathContextFactoryConfigurationError(final Exception cause, final String msg) {
+        super(msg, cause);
     }
 
     /**
@@ -62,7 +57,6 @@ public class JXPathContextFactoryConfigurationError extends Error {
      */
     public JXPathContextFactoryConfigurationError(final String msg) {
         super(msg);
-        this.exception = null;
     }
 
     /**
@@ -71,21 +65,7 @@ public class JXPathContextFactoryConfigurationError extends Error {
      * @return The encapsulated exception, or null if there is none.
      */
     public Exception getException() {
-        return exception;
+        return (Exception) super.getCause();
     }
 
-    /**
-     * Gets the message (if any) for this error . If there is no message for the exception and there is an encapsulated exception then the message of that
-     * exception will be returned.
-     *
-     * @return The error message.
-     */
-    @Override
-    public String getMessage() {
-        final String message = super.getMessage();
-        if (message == null && exception != null) {
-            return exception.getMessage();
-        }
-        return message;
-    }
 }
diff --git a/src/main/java/org/apache/commons/jxpath/JXPathException.java b/src/main/java/org/apache/commons/jxpath/JXPathException.java
index 999744a..7ad18b2 100644
--- a/src/main/java/org/apache/commons/jxpath/JXPathException.java
+++ b/src/main/java/org/apache/commons/jxpath/JXPathException.java
@@ -22,7 +22,7 @@ package org.apache.commons.jxpath;
  */
 public class JXPathException extends RuntimeException {
 
-    private static final long serialVersionUID = 4306409701468017766L;
+    private static final long serialVersionUID = 2L;
 
     /**
      * Create a new {@code JXPathException} with no detail mesage.