You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2026/07/29 05:43:20 UTC
(sling-org-apache-sling-resourceresolver) 01/01: SLING-13277: use java.nio.charset.CharSet to instantiate the String (backport to 1.x)
This is an automated email from the ASF dual-hosted git repository.
royteeuwen pushed a commit to branch backport/SLING-13277-1.x
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 9078f2e42f74537647ee5155c1c776006c988519
Author: Julian Reschke <ju...@gmx.de>
AuthorDate: Thu Jul 9 17:50:03 2026 +0200
SLING-13277: use java.nio.charset.CharSet to instantiate the String (backport to 1.x)
Cherry-picked from master since this fix was never backported to the
1.x maintenance branch.
(cherry picked from commit 08e778693e9a5f9f2e5ceeb30c67ba3202928e4a)
---
.../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);
}
/**