CSV-242 CSVFormat equals() and hashCode() don't use all fields
Fix hashCode()
This commit is contained in:
parent
46c84341e6
commit
c683594f59
|
@ -39,6 +39,7 @@
|
|||
</properties>
|
||||
<body>
|
||||
<release version="1.8" date="2019-MM-DD" description="Feature and bug fix release (Java 8)">
|
||||
<action issue="CSV-242" type="fix" dev="sebb">CSVFormat equals() and hash() don't use all fields</action>
|
||||
<action issue="CSV-241" type="fix" dev="ggregory" due-to="LuckyIlam, Gary Gregory">CSVFormat#valiadte() does not account for allowDuplicateHeaderNames #43.</action>
|
||||
</release>
|
||||
<release version="1.7" date="2019-06-01" description="Feature and bug fix release (Java 8)">
|
||||
|
|
|
@ -1089,8 +1089,14 @@ public final class CSVFormat implements Serializable {
|
|||
result = prime * result + (ignoreHeaderCase ? 1231 : 1237);
|
||||
result = prime * result + (ignoreEmptyLines ? 1231 : 1237);
|
||||
result = prime * result + (skipHeaderRecord ? 1231 : 1237);
|
||||
result = prime * result + (allowDuplicateHeaderNames ? 1231 : 1237);
|
||||
result = prime * result + (trim ? 1231 : 1237);
|
||||
result = prime * result + (autoFlush ? 1231 : 1237);
|
||||
result = prime * result + (trailingDelimiter ? 1231 : 1237);
|
||||
result = prime * result + (allowMissingColumnNames ? 1231 : 1237);
|
||||
result = prime * result + ((recordSeparator == null) ? 0 : recordSeparator.hashCode());
|
||||
result = prime * result + Arrays.hashCode(header);
|
||||
result = prime * result + Arrays.hashCode(headerComments);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1112,7 +1112,10 @@ public class CSVFormatTest {
|
|||
|
||||
private void assertNotEquals(String name, String type, Object left, Object right) {
|
||||
if (left.equals(right) || right.equals(left)) {
|
||||
System.out.println("Should not be equal for " + name + "(" + type + ")");
|
||||
fail("Objects must not compare equal for " + name + "(" + type + ")");
|
||||
}
|
||||
if (left.hashCode() == right.hashCode()) {
|
||||
fail("Hash code not be equal for " + name + "(" + type + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue