diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-12-29 19:50:29 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-12-29 19:50:29 +0100 |
commit | 29ddbf7fcd48f167e4a02b6ee61e9f8697a7175c (patch) | |
tree | a2e73fd6cb3cfa1f1d88ae3c76e05076816cb7c5 /org.eclipse.jgit | |
parent | f211bfc8411cd57e6591cbacab21e004a14553dd (diff) | |
download | jgit-29ddbf7fcd48f167e4a02b6ee61e9f8697a7175c.tar.gz jgit-29ddbf7fcd48f167e4a02b6ee61e9f8697a7175c.zip |
[findBugs] Remove reliance on default encoding in Base64
Change-Id: I6901da975a86c460ce7c783a519669d8be8e23bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java index ed5838a20e..c05570b851 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java @@ -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); } } |