aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src/main/java/org/sonar/duplications/index
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-duplications/src/main/java/org/sonar/duplications/index')
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java6
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java6
2 files changed, 8 insertions, 4 deletions
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java
index b840c2f55f0..818e018d4bb 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/CloneGroup.java
@@ -23,6 +23,8 @@ import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
+import javax.annotation.Nullable;
+
import java.util.ArrayList;
import java.util.List;
@@ -134,8 +136,8 @@ public class CloneGroup {
* Two groups are equal, if they have same length, same origins and contain same parts in same order.
*/
@Override
- public boolean equals(Object object) {
- if (this.getClass() != object.getClass()) {
+ public boolean equals(@Nullable Object object) {
+ if (object == null || this.getClass() != object.getClass()) {
return false;
}
CloneGroup another = (CloneGroup) object;
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java b/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java
index 630f52c1350..0130f167197 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/index/ClonePart.java
@@ -21,6 +21,8 @@ package org.sonar.duplications.index;
import org.sonar.duplications.CodeFragment;
+import javax.annotation.Nullable;
+
public class ClonePart implements CodeFragment {
private final String resourceId;
@@ -63,8 +65,8 @@ public class ClonePart implements CodeFragment {
}
@Override
- public boolean equals(Object obj) {
- if (this.getClass() == obj.getClass()) {
+ public boolean equals(@Nullable Object obj) {
+ if (obj != null && this.getClass() == obj.getClass()) {
ClonePart another = (ClonePart) obj;
return another.resourceId.equals(resourceId)
&& another.startLine == startLine