Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-3342

Use StandardCharsets

    XMLWordPrintableJSON

Details

    Description

      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--

      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/

      Attachments

        Issue Links

          Activity

            People

              belugabehr David Mollitor
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h 20m
                  5h 20m