Skip to content

Commit 280e477

Browse files
author
Vladimir Kotal
committed
adjust hashCode for message stripping
1 parent 2f2091d commit 280e477

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,14 @@ private int getHashCode(Object o) {
231231
return o.hashCode();
232232
}
233233

234+
private static String stripMessage(String message) {
235+
if (message == null) {
236+
return null;
237+
}
238+
239+
return message.stripLeading().stripTrailing();
240+
}
241+
234242
@Override
235243
public boolean equals(Object o) {
236244
if (this == o) {
@@ -243,11 +251,11 @@ public boolean equals(Object o) {
243251

244252
String thisMessage = this.getMessage();
245253
if (thisMessage != null) {
246-
thisMessage = thisMessage.stripLeading().stripTrailing();
254+
thisMessage = stripMessage(thisMessage);
247255
}
248256
String thatMessage = that.getMessage();
249257
if (thatMessage != null) {
250-
thatMessage = thatMessage.stripLeading().stripTrailing();
258+
thatMessage = stripMessage(thatMessage);
251259
}
252260

253261
return checkEquals(this.getAuthor(), that.getAuthor()) &&
@@ -261,6 +269,6 @@ public boolean equals(Object o) {
261269
@Override
262270
public int hashCode() {
263271
return getHashCode(getAuthor()) + getHashCode(getRevision()) + getHashCode(getDate()) +
264-
getHashCode(getMessage()) + getHashCode(getFiles()) + getHashCode(getTags());
272+
getHashCode(stripMessage(getMessage())) + getHashCode(getFiles()) + getHashCode(getTags());
265273
}
266274
}

0 commit comments

Comments
 (0)