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

reschke pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git


The following commit(s) were added to refs/heads/master by this push:
     new 08e77869 SLING-13260: use java.nio.charset.CharSet to instantiate the 
String
08e77869 is described below

commit 08e778693e9a5f9f2e5ceeb30c67ba3202928e4a
Author: Julian Reschke <[email protected]>
AuthorDate: Thu Jul 9 17:50:03 2026 +0200

    SLING-13260: use java.nio.charset.CharSet to instantiate the String
---
 .../apache/sling/resourceresolver/impl/helper/URI.java    | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java 
b/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java
index f9c81020..1db31a2b 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/helper/URI.java
@@ -24,6 +24,7 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.BitSet;
 import java.util.HashMap;
@@ -4007,8 +4008,6 @@ public class URI implements Cloneable, Comparable<URI>, 
Serializable {
      * headers)
      *
      * @param data the byte array to be encoded
-     * @param offset the index of the first byte to encode
-     * @param length the number of bytes to encode
      * @return The string representation of the byte array
      * @since 3.0
      */
@@ -4018,11 +4017,7 @@ public class URI implements Cloneable, Comparable<URI>, 
Serializable {
             throw new IllegalArgumentException("Parameter may not be null");
         }
 
-        try {
-            return new String(data, "US-ASCII");
-        } catch (UnsupportedEncodingException e) {
-            throw new URIException("HttpClient requires ASCII support");
-        }
+        return new String(data, StandardCharsets.US_ASCII);
     }
 
     /**
@@ -4069,11 +4064,7 @@ public class URI implements Cloneable, Comparable<URI>, 
Serializable {
             throw new IllegalArgumentException("Parameter may not be null");
         }
 
-        try {
-            return data.getBytes("US-ASCII");
-        } catch (UnsupportedEncodingException e) {
-            throw new URIException("HttpClient requires ASCII support");
-        }
+        return data.getBytes(StandardCharsets.US_ASCII);
     }
 
     /**

Reply via email to