[ https://issues.apache.org/jira/browse/HADOOP-16073?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16762345#comment-16762345 ]
BELUGA BEHR commented on HADOOP-16073: -------------------------------------- Or, if you would like some examples of using it beyond consistency: {code:java} - secret = sb.toString().getBytes(Charset.forName("UTF-8")); + secret = sb.toString().getBytes(StandardCharsets.UTF_8); {code} In these situations, Java does not have to load the UTF-8 Charset every call, it can simply use the one that is already defined. {code:java} - try { - return new String(bb.array(), bb.arrayOffset() + bb.position(), - bb.remaining(), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalCharsetNameException("UTF-8"); // won't happen. - } + return new String(bb.array(), bb.arrayOffset() + bb.position(), + bb.remaining(), StandardCharsets.UTF_8); {code} Since the JDK is required to provide this implementation, there is no need to catch "no such character set" exceptions. Leaner and quicker code. > Use JDK1.7 StandardCharsets > --------------------------- > > Key: HADOOP-16073 > URL: https://issues.apache.org/jira/browse/HADOOP-16073 > Project: Hadoop Common > Issue Type: Improvement > Affects Versions: 3.2.0 > Reporter: BELUGA BEHR > Assignee: BELUGA BEHR > Priority: Major > Attachments: HADOOP-16073.1.patch > > > Use Java 1.7 > [StandardCharsets|https://docs.oracle.com/javase/7/docs/api/java/nio/charset/StandardCharsets.html]. > Every JDK must now include support for several common charsets. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org