JC created SLIDER-1235:
--------------------------

             Summary: Potential bugs in equals implementation
                 Key: SLIDER-1235
                 URL: https://issues.apache.org/jira/browse/SLIDER-1235
             Project: Slider
          Issue Type: Bug
          Components: core
            Reporter: JC
            Priority: Trivial


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

{code: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   }
{code}

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!



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to