]> source.dussan.org Git - jgit.git/commitdiff
[findBugs] Remove reliance on default encoding in Base64 10/87810/1
authorMatthias Sohn <matthias.sohn@sap.com>
Thu, 29 Dec 2016 18:50:29 +0000 (19:50 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 29 Dec 2016 18:50:29 +0000 (19:50 +0100)
Change-Id: I6901da975a86c460ce7c783a519669d8be8e23bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java

index ed5838a20e036d0f59cc7215db12bdc4e7ac0957..c05570b85164b5e3d77feca8f88e6948be2953d9 100644 (file)
@@ -7,6 +7,7 @@
 package org.eclipse.jgit.util;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.text.MessageFormat;
 import java.util.Arrays;
 
@@ -184,11 +185,7 @@ public class Base64 {
                        e += 4;
                }
 
-               try {
-                       return new String(outBuff, 0, e, UTF_8);
-               } catch (UnsupportedEncodingException uue) {
-                       return new String(outBuff, 0, e);
-               }
+               return new String(outBuff, 0, e, StandardCharsets.UTF_8);
        }
 
        /**
@@ -304,12 +301,7 @@ public class Base64 {
         * @return the decoded data
         */
        public static byte[] decode(String s) {
-               byte[] bytes;
-               try {
-                       bytes = s.getBytes(UTF_8);
-               } catch (UnsupportedEncodingException uee) {
-                       bytes = s.getBytes();
-               }
+               byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
                return decode(bytes, 0, bytes.length);
        }
 }