Menu

#59 Record.getRRsetType() causes ClassCastException

None
closed
nobody
None
5
2019-05-18
2017-11-29
No

I came across a case where I got a ClassCastException in the Record.getRRSetType method. The cause was that I had a message containing (at least) two RRSIG records in the query section and used to Message.toWire method to convert the message to the binary format. The Message.sectionToWire tries find RRSet boundaries and calls sameRRset for this purpose, which calls the method in question to derive the types of the two records.

The method tests for the RRSIG type and then tries to downcast the reference to an RRSIGRecord. However this fails as the entries in the query section may be represented by EmptyRecord and not only by RRSIGRecord.

There are two ways to fix it: Either change the comparison to an "instanceof" check (see patch), or – more object oriented – return the "type" member variable in the default Record class implementation and override the method in the SIGBase class, returning the "covered" member variable.

1 Attachments

Discussion

  • Brian Wellington

    I don't think either of these solutions is correct; I think the problem is that calling Record.getRRSetType doesn't make sense for records in the query section of a message, as they shouldn't be combined into RRSets.

     
  • Ingo

    Ingo - 2019-05-18

    If you still think this is an issue/use case, please create a pull request on dnsjava's new home at Github: https://github.com/dnsjava/dnsjava

     
  • Ingo

    Ingo - 2019-05-18
    • status: open --> closed
    • Group: -->