Uploaded image for project: 'Slider'
  1. Slider
  2. SLIDER-1235

Potential bugs in equals implementation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • None
    • None
    • core
    • None

    Description

      Hi

      In a recent github mirror, I've found the following suspicious code.
      Path: slider-core/src/main/java/org/apache/slider/providers/agent/ComponentInstanceState.java

      169   public boolean equals(Object o) {
      170     if (this == o) return true;
      171 
      172     if (o == null || getClass() != o.getClass()) return false;
      173 
      174     ComponentInstanceState that = (ComponentInstanceState) o;
      175 
      176     if (this.componentName != null ?
      177         !this.componentName.equals(that.componentName) : this.componentName != null) {
      178       return false;
      179     }
      180 
      181     if (this.containerIdAsString != null ?
      182         !this.containerIdAsString.equals(that.containerIdAsString) : this.containerIdAsString != null) {
      183       return false;
      184     }
      185 
      186     if (this.applicationId != null ?
      187         !this.applicationId.equals(that.applicationId) : this.applicationId != null) {
      188       return false;
      189     }
      190 
      191     return true;
      192   }
      

      In Line 177, 'this.componentName != null' is repeated as this already in Line 176. Should the second one be 'that.componentName != null'? In Line 182 and 187, there are similar issues.
      The current code will not return false when this.xxx is null but that.xxx is not null as this.xxx
      (the second one) will return always false. Since I don't have domain knowledge about this project, these might be trivial things. But I wanted to report just in case.

      Thanks!

      Attachments

        Activity

          People

            Unassigned Unassigned
            lifove JC
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: