Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-6252

Suspicious code fragments: comparing with itself

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 3.0.0-alpha2
    • None
    • None
    • None

    Description

      Hi

      1)
      https://github.com/apache/hadoop/blob/235203dffda1482fb38762fde544c4dd9c3e1fa8/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ReservationId.java#L106

            return getId() > getId() ? 1 : getId() < getId() ? -1 : 0;
      

      strangely, than getId() compare with itself
      Probably It should be something like this:

            return this.getId() > other.getId() ? 1 : this.getId() < other.getId() ? -1 : 0;
      

      2) https://github.com/apache/hadoop/blob/235203dffda1482fb38762fde544c4dd9c3e1fa8/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestAppLogAggregatorImpl.java#L260

          if(filesUploaded.size() != filesUploaded.size()) {
            fail(errMsgPrefix + ": actual size: " + filesUploaded.size() + " vs " +
                "expected size: " + filesExpected.size());
          }
      

      filesUploaded.size() compare with it self
      probably it should be:

          if(filesUploaded.size() != filesExpected.size()) {
            fail(errMsgPrefix + ": actual size: " + filesUploaded.size() + " vs " +
                "expected size: " + filesExpected.size());
          }
      

      These possible defects found by static code analyzer AppChecker

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            haibochen Haibo Chen
            AppChecker AppChecker
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment