[findBugs] Remove reliance on default encoding in Base64

Change-Id: I6901da975a86c460ce7c783a519669d8be8e23bb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2016-12-29 19:50:29 +01:00
parent f211bfc841
commit 29ddbf7fcd
1 changed files with 3 additions and 11 deletions

View 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 static String encodeBytes(byte[] source, int off, int len) {
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 static byte[] decode(byte[] source, int off, int len) {
* @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);
}
}