Menu

#49 TTL field of OPTRecord should be considered in equals()

None
closed-fixed
nobody
None
5
2014-12-22
2014-10-31
No

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();
}
1 Attachments

Discussion

  • Brian Wellington

    • Group: -->
     
  • Brian Wellington

    I agree. I'm fixing this, but I think the equals() method can be simplified to:

    return super.equals(arg) && ttl == ((OPTRecord) arg).ttl;

     
  • Brian Wellington

    • status: open --> closed-fixed