[java-shib-shared] branch main updated: Use built-in literal for UTF-8 in place of string parameter.

Scott Cantor cantor.2 at osu.edu
Wed Sep 18 14:15:31 UTC 2024


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=2da94b729d91552cc2bd9fa33a228782e1f3a599

The following commit(s) were added to refs/heads/main by this push:
     new 2da94b72 Use built-in literal for UTF-8 in place of string parameter.
2da94b72 is described below

commit 2da94b729d91552cc2bd9fa33a228782e1f3a599
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Sep 18 10:15:28 2024 -0400

    Use built-in literal for UTF-8 in place of string parameter.
---
 .../java/net/shibboleth/shared/xml/SerializeSupport.java | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/shib-support/src/main/java/net/shibboleth/shared/xml/SerializeSupport.java b/shib-support/src/main/java/net/shibboleth/shared/xml/SerializeSupport.java
index 37227f52..a8bda213 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/xml/SerializeSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/xml/SerializeSupport.java
@@ -16,7 +16,7 @@ package net.shibboleth.shared.xml;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 import javax.annotation.Nonnull;
@@ -71,12 +71,7 @@ public final class SerializeSupport {
 
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         writeNode(node, baout, serializerParams);
-        try {
-            return new String(baout.toByteArray(), "UTF-8");
-        } catch (final UnsupportedEncodingException e) {
-            // all VMs are required to support UTF-8, if it's not something is really wrong
-            throw new RuntimeException(e);
-        }
+        return new String(baout.toByteArray(), StandardCharsets.UTF_8);
     }
     
     /**
@@ -92,12 +87,7 @@ public final class SerializeSupport {
         
         final ByteArrayOutputStream baout = new ByteArrayOutputStream();
         writeNode(node, baout, prettyPrintParams);
-        try {
-            return new String(baout.toByteArray(), "UTF-8");
-        } catch (final UnsupportedEncodingException e) {
-            // all VMs are required to support UTF-8, if it's not something is really wrong
-            throw new RuntimeException(e);
-        }
+        return new String(baout.toByteArray(), StandardCharsets.UTF_8);
     }
 
     /**

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list