Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4709

Use StandardCharset UTF-8

    XMLWordPrintableJSON

Details

    Description

      AS I understand it, starting with Java 1.7, all JVM must support the UTF-8 charset. Prior to JDK 7, it was required to do something like:

      TJSONProtocol.java
          try {
            byte[] buf = str.getBytes("UTF-8");
            trans_.write(buf);
          } catch (UnsupportedEncodingException uex) {
            throw new TException("JVM DOES NOT SUPPORT UTF-8");
          }
      

      However, now there is available java.nio.charset.StandardCharsets which provides the required charsets and therefore there is no longer a need to do a try/catch to encode/decode Strings and UTF-8 byte arrays. This will save on lines of code and removes the overhead of the try/catch block.

      Attachments

        Issue Links

          Activity

            People

              jking3 James E. King III
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 20m
                  20m