Wire format's TTL field within OPT is defined differently according to RFC 2671 (chapter 4.3). Semantics of these fields are of much higher importance compared to a "simple" TTL, so content of this field should be considered within OPTRecord's equals() method. I myself get in trouble in my current project missing this feature ... :-)
As attachments a unit test file containing test cases to check OPTRecord instances with different EDNS VERSION or EDNS RCODE values, respectively. The following implementation of OPTRecord.equals() makes the unit tests pass:
@Override
public boolean equals(final Object arg) {
if (!super.equals(arg)) {
return false;
}
if (!(arg instanceof OPTRecord)) {
return false;
}
final OPTRecord other = (OPTRecord) arg;
return getTTL() == other.getTTL();
}
I agree. I'm fixing this, but I think the equals() method can be simplified to:
return super.equals(arg) && ttl == ((OPTRecord) arg).ttl;