Uploaded image for project: 'Chukwa'
  1. Chukwa
  2. CHUKWA-816

A suspicious use of incrementer in a for statement

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 0.6.0, 0.7.0, 0.8.0
    • Fix Version/s: 0.9.0
    • Component/s: None
    • Labels:
      None

      Description

      Is this incorrect use of incrementers in this for statement?
      (From the recent snapshot in github mirror. Path: src/main/java/org/apache/hadoop/chukwa/rest/bean/WidgetBean.java

      In Line 170, plist[i] should be plist[j] and parameters[j] should be parameters[i]??

      167           for(int i=0;i<this.parameters.length;i++) {
      168             Collection<String> value = this.parameters[i].getValue();
      169             for(int j=0;j<plist.length;j++) {
      170               if(plist[i].getName().intern()==this.parameters[j].getName().intern()) {
      171                 plist[j].setValue(value);
      172               }
      173             }
      174           }
      175           this.parameters=plist;
      

      Since I do not have domain knowledge, I have no idea if parameters.length and plist.length is always same. But, I thought it might be worth to report just in case.

        Issue Links

          Activity

          Hide
          eyang Eric Yang added a comment -

          Good catch. "i" and "j" should be swapped in line 170 for correctness. Patch are welcome.

          Show
          eyang Eric Yang added a comment - Good catch. "i" and "j" should be swapped in line 170 for correctness. Patch are welcome.
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user lifove opened a pull request:

          https://github.com/apache/chukwa/pull/5

          CHUKWA-816. Fix wrong use of incrementers in a for loop.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/lifove/chukwa master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/chukwa/pull/5.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #5


          commit d861af881a8c36d8e51a795f2056f376454b9514
          Author: JC <jc@lifove.net>
          Date: 2017-02-02T03:23:48Z

          CHUKWA-816. Fix wrong use of incrementers in a for loop.


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user lifove opened a pull request: https://github.com/apache/chukwa/pull/5 CHUKWA-816 . Fix wrong use of incrementers in a for loop. You can merge this pull request into a Git repository by running: $ git pull https://github.com/lifove/chukwa master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/chukwa/pull/5.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #5 commit d861af881a8c36d8e51a795f2056f376454b9514 Author: JC <jc@lifove.net> Date: 2017-02-02T03:23:48Z CHUKWA-816 . Fix wrong use of incrementers in a for loop.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/chukwa/pull/5

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/chukwa/pull/5
          Hide
          eyang Eric Yang added a comment -

          +1 looks good.

          Show
          eyang Eric Yang added a comment - +1 looks good.
          Hide
          eyang Eric Yang added a comment -

          I just committed this. Thank you, Jaechang.

          Show
          eyang Eric Yang added a comment - I just committed this. Thank you, Jaechang.
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Chukwa-master #579 (See https://builds.apache.org/job/Chukwa-master/579/)
          CHUKWA-816. Fix wrong use of incrementers in a for loop. (eyang: rev ffd0d400ebd911ffa88bb9a46b08a261bc999dd6)

          • (edit) src/main/java/org/apache/hadoop/chukwa/rest/bean/WidgetBean.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Chukwa-master #579 (See https://builds.apache.org/job/Chukwa-master/579/ ) CHUKWA-816 . Fix wrong use of incrementers in a for loop. (eyang: rev ffd0d400ebd911ffa88bb9a46b08a261bc999dd6) (edit) src/main/java/org/apache/hadoop/chukwa/rest/bean/WidgetBean.java

            People

            • Assignee:
              lifove JC
              Reporter:
              lifove JC
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development