Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-13953

Issues in HiveLockObject equals method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.0
    • Component/s: Locking
    • Labels:
      None

      Description

      There are two issues in equals method in HiveLockObject:

        @Override
        public boolean equals(Object o) {
          if (!(o instanceof HiveLockObject)) {
            return false;
          }
      
          HiveLockObject tgt = (HiveLockObject) o;
          return Arrays.equals(pathNames, tgt.pathNames) &&
              data == null ? tgt.getData() == null :
              tgt.getData() != null && data.equals(tgt.getData());
        }
      

      1. Arrays.equals(pathNames, tgt.pathNames) might return false for the same path in HiveLockObject since in current Hive, the pathname components might be stored in two ways, taking a dynamic partition path db/tbl/part1/part2 as an example, it might be stored in the pathNames as an array of four elements, db, tbl, part1, and part2 or as an array only having one element db/tbl/part1/part2. It will be safer to comparing the pathNames using StringUtils.equals(this.getName(), tgt.getName())
      2. The comparison logic is not right.

        @Override
        public boolean equals(Object o) {
          if (!(o instanceof HiveLockObject)) {
            return false;
          }
      
          HiveLockObject tgt = (HiveLockObject) o;
          return StringUtils.equals(this.getName(), tgt.getName()) &&
              (data == null ? tgt.getData() == null : data.equals(tgt.getData()));
        }
      

        Attachments

          Activity

            People

            • Assignee:
              ctang.ma Chaoyu Tang
              Reporter:
              ctang.ma Chaoyu Tang
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: