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-codec.git

commit 9245cf65a700bb6d5d78890dd039e7860a9133b5
Author: Gary D. Gregory <[email protected]>
AuthorDate: Thu Oct 2 18:18:09 2025 -0400

    Add DecoderException.DecoderException(String, Object...)
---
 src/changes/changes.xml                                    |  1 +
 .../java/org/apache/commons/codec/DecoderException.java    | 14 ++++++++++++++
 .../org/apache/commons/codec/DecoderExceptionTest.java     |  7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 76282c7c..dd213820 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -52,6 +52,7 @@ The <action> type attribute can be add,update,fix,remove.
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Fredrik Kjellberg, Gary 
Gregory">Add org.apache.commons.codec.digest.CRC16.</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add builders to 
org.apache.commons.codec.digest streams and deprecate some old 
constructors.</action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
DecoderException.DecoderException(String, Object...).</action>
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory, 
Dependabot">Bump org.apache.commons:commons-parent from 85 to 88.</action>
       <action type="update" dev="ggregory" due-to="Gary Gregory">[test] Bump 
org.apache.commons:commons-lang3 from 3.18.0 to 3.19.0.</action>
diff --git a/src/main/java/org/apache/commons/codec/DecoderException.java 
b/src/main/java/org/apache/commons/codec/DecoderException.java
index 4fed6663..98ba6593 100644
--- a/src/main/java/org/apache/commons/codec/DecoderException.java
+++ b/src/main/java/org/apache/commons/codec/DecoderException.java
@@ -50,6 +50,20 @@ public class DecoderException extends Exception {
         super(message);
     }
 
+    /**
+     * Constructs a new exception with the specified detail message. The cause 
is not initialized, and may subsequently be initialized by a call to
+     * {@link #initCause}.
+     *
+     * @param message The format message which is saved for later retrieval by 
the {@link #getMessage()} method.
+     * @param args    the format arguments to use.
+     *
+     * @see String#format(String, Object...)
+     * @since 1.20
+     */
+    public DecoderException(final String message, Object... args) {
+        super(String.format(message, args));
+    }
+
     /**
      * Constructs a new exception with the specified detail message and cause.
      * <p>
diff --git a/src/test/java/org/apache/commons/codec/DecoderExceptionTest.java 
b/src/test/java/org/apache/commons/codec/DecoderExceptionTest.java
index c9c19f2c..47a3c59a 100644
--- a/src/test/java/org/apache/commons/codec/DecoderExceptionTest.java
+++ b/src/test/java/org/apache/commons/codec/DecoderExceptionTest.java
@@ -45,6 +45,13 @@ class DecoderExceptionTest {
         assertNull(e.getCause());
     }
 
+    @Test
+    void testConstructorStringObjectArray() {
+        final DecoderException e = new DecoderException("Hello %s", "World!");
+        assertEquals("Hello World!", e.getMessage());
+        assertNull(e.getCause());
+    }
+
     @Test
     void testConstructorStringThrowable() {
         final DecoderException e = new DecoderException(MSG, t);

Reply via email to