[
https://issues.apache.org/jira/browse/ZOOKEEPER-3342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Mollitor updated ZOOKEEPER-3342:
--------------------------------------
Description:
{quote}
Encodes this String into a sequence of bytes using the platform's default
charset, storing the result into a new byte array. The behavior of this method
when this string cannot be encoded in the default charset is unspecified.
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#getBytes--
{quote}
Since this is a distributed system, it is always possible that different nodes
have different default charsets defined. I think it's most safe to specify it
explicitly across all nodes for safety sake. You could for example see a
situation where an upgrade JVM uses a different default and during a rolling
upgrade of the JVM, different nodes now have a different default.
* The default charset is usually "ISO-8859-1". UTF-8 covers more of our
international friends.
* Explicitly specifying the CharSet yields slight performance gains
* Explicitly specifying the CharSet removes the need for try/catch blocks of
UnsupportedEncodingException
https://blog.codecentric.de/en/2014/04/faster-cleaner-code-since-java-7/
> Use StandardCharsets
> --------------------
>
> Key: ZOOKEEPER-3342
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3342
> Project: ZooKeeper
> Issue Type: Improvement
> Reporter: David Mollitor
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> {quote}
> Encodes this String into a sequence of bytes using the platform's default
> charset, storing the result into a new byte array. The behavior of this
> method when this string cannot be encoded in the default charset is
> unspecified.
> https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#getBytes--
> {quote}
> Since this is a distributed system, it is always possible that different
> nodes have different default charsets defined. I think it's most safe to
> specify it explicitly across all nodes for safety sake. You could for example
> see a situation where an upgrade JVM uses a different default and during a
> rolling upgrade of the JVM, different nodes now have a different default.
> * The default charset is usually "ISO-8859-1". UTF-8 covers more of our
> international friends.
> * Explicitly specifying the CharSet yields slight performance gains
> * Explicitly specifying the CharSet removes the need for try/catch blocks of
> UnsupportedEncodingException
> https://blog.codecentric.de/en/2014/04/faster-cleaner-code-since-java-7/
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)