You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@rocketmq.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2017/05/25 06:03:04 UTC

[jira] [Commented] (ROCKETMQ-206) Load JSON config file error if non-1byte character exists

    [ https://issues.apache.org/jira/browse/ROCKETMQ-206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16024243#comment-16024243 ] 

ASF subversion and git services commented on ROCKETMQ-206:
----------------------------------------------------------

Commit ceeef8ec25758eea490b39400328dd8a702b0175 in incubator-rocketmq's branch refs/heads/ROCKETMQ-206 from [~Yukon]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=ceeef8e ]

[ROCKETMQ-206] Fix bug when non-1byte character exists in JSON config files.


> Load JSON config file error if non-1byte character exists
> ---------------------------------------------------------
>
>                 Key: ROCKETMQ-206
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-206
>             Project: Apache RocketMQ
>          Issue Type: Bug
>          Components: rocketmq-commons
>    Affects Versions: 4.0.0-incubating
>            Reporter: yukon
>            Assignee: yukon
>             Fix For: 4.1.0-incubating
>
>
> If there are some non-1byte character in consumeroffset.json or other config files, when Broker restarted, the file contents will be ignored.
> See this method, when file.length() != character number, bug triggered.
> {code}
> public static String file2String(final File file) {
>         if (file.exists()) {
>             char[] data = new char[(int) file.length()];
>             boolean result = false;
>             FileReader fileReader = null;
>             try {
>                 fileReader = new FileReader(file);
>                 int len = fileReader.read(data);
>                 result = len == data.length;
>             } catch (IOException e) {
>                 // e.printStackTrace();
>             } finally {
>                 if (fileReader != null) {
>                     try {
>                         fileReader.close();
>                     } catch (IOException e) {
>                         e.printStackTrace();
>                     }
>                 }
>             }
>             if (result) {
>                 return new String(data);
>             }
>         }
>         return null;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)