thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James E. King III (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (THRIFT-4709) Use StandardCharset UTF-8
Date Thu, 03 Jan 2019 05:12:00 GMT

     [ https://issues.apache.org/jira/browse/THRIFT-4709?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

James E. King III updated THRIFT-4709:
--------------------------------------
    Labels: Breaking-Change  (was: )

> Use StandardCharset UTF-8
> -------------------------
>
>                 Key: THRIFT-4709
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4709
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Library
>    Affects Versions: 0.12.0
>            Reporter: BELUGA BEHR
>            Assignee: James E. King III
>            Priority: Minor
>              Labels: Breaking-Change
>             Fix For: 1.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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:
> {code:java|title=TJSONProtocol.java}
>     try {
>       byte[] buf = str.getBytes("UTF-8");
>       trans_.write(buf);
>     } catch (UnsupportedEncodingException uex) {
>       throw new TException("JVM DOES NOT SUPPORT UTF-8");
>     }
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message