Details
-
Improvement
-
Status: Closed
-
Trivial
-
Resolution: Fixed
-
3.0.0, 4.0.0
Description
try { String signatureString = job.get("base64.text.output.format.signature"); if (signatureString != null) { signature = signatureString.getBytes("UTF-8"); } else { signature = new byte[0]; } } catch (UnsupportedEncodingException e) { e.printStackTrace(); }
The UnsupportedEncodingException is coming from the getBytes method call. Instead, use the CharSet version of the method and it doesn't throw this explicit exception so the 'try' block can simply be removed. Every JVM will support UTF-8.
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes(java.nio.charset.Charset)
https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html#UTF_8