Uploaded image for project: 'Apache RocketMQ'
  1. Apache RocketMQ
  2. ROCKETMQ-206

Load JSON config file error if non-1byte character exists

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.0-incubating
    • Fix Version/s: 4.1.0-incubating
    • Component/s: rocketmq-commons
    • Labels:
      None

      Description

      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.

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

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        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.

        Show
        jira-bot ASF subversion and git services added a comment - 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.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit ceeef8ec25758eea490b39400328dd8a702b0175 in incubator-rocketmq's branch refs/heads/develop 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.

        Show
        jira-bot ASF subversion and git services added a comment - Commit ceeef8ec25758eea490b39400328dd8a702b0175 in incubator-rocketmq's branch refs/heads/develop 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.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit e5d01b4121c3e17be8073752510a7ca78dd2bf76 in incubator-rocketmq's branch refs/heads/develop from dongeforever
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=e5d01b4 ]

        Merge branch 'ROCKETMQ-206' into develop

        Show
        jira-bot ASF subversion and git services added a comment - Commit e5d01b4121c3e17be8073752510a7ca78dd2bf76 in incubator-rocketmq's branch refs/heads/develop from dongeforever [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=e5d01b4 ] Merge branch ' ROCKETMQ-206 ' into develop
        Hide
        zander dongeforever added a comment -

        this has been merged from branch ROCKETMQ-206

        Show
        zander dongeforever added a comment - this has been merged from branch ROCKETMQ-206
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        ROCKETMQ-206 Catch the IOException when call the file2String method.

        Show
        jira-bot ASF subversion and git services added a comment - Commit aced0de7d8f98a01d9d109dd592a6cb31fd174d9 in incubator-rocketmq's branch refs/heads/ ROCKETMQ-206 from yukon [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=aced0de ] ROCKETMQ-206 Catch the IOException when call the file2String method.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit aced0de7d8f98a01d9d109dd592a6cb31fd174d9 in incubator-rocketmq's branch refs/heads/develop from yukon
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=aced0de ]

        ROCKETMQ-206 Catch the IOException when call the file2String method.

        Show
        jira-bot ASF subversion and git services added a comment - Commit aced0de7d8f98a01d9d109dd592a6cb31fd174d9 in incubator-rocketmq's branch refs/heads/develop from yukon [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=aced0de ] ROCKETMQ-206 Catch the IOException when call the file2String method.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit e57f9ac433bdf4ec640089ccaf580954e93f50dc in incubator-rocketmq's branch refs/heads/develop from dongeforever
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=e57f9ac ]

        Merge remote-tracking branch 'wip/ROCKETMQ-206' into develop

        Show
        jira-bot ASF subversion and git services added a comment - Commit e57f9ac433bdf4ec640089ccaf580954e93f50dc in incubator-rocketmq's branch refs/heads/develop from dongeforever [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=e57f9ac ] Merge remote-tracking branch 'wip/ ROCKETMQ-206 ' into develop
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 3292d039ae882f42168d5f98969df83130ca05fb in incubator-rocketmq's branch refs/heads/master from yukon
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=3292d03 ]

        ROCKETMQ-206 Catch the IOException when call the file2String method.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 3292d039ae882f42168d5f98969df83130ca05fb in incubator-rocketmq's branch refs/heads/master from yukon [ https://git-wip-us.apache.org/repos/asf?p=incubator-rocketmq.git;h=3292d03 ] ROCKETMQ-206 Catch the IOException when call the file2String method.

          People

          • Assignee:
            Yukon yukon
            Reporter:
            Yukon yukon
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development