rawlinp commented on a change in pull request #4409: Optimize TR DNSSEC zone
re-signing
URL: https://github.com/apache/trafficcontrol/pull/4409#discussion_r382152225
##########
File path:
traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/dns/ZoneManager.java
##########
@@ -538,6 +596,42 @@ private static void primeDNSDeliveryServices(final String
domain, final TrafficR
}
}
+ // Check if the zones are equal except for the SOA record serial
number, NSEC, or RRSIG records
+ private static boolean zonesAreEqual(final List<Record> newRecords,
final List<Record> oldRecords) {
+ final List<Record> oldRecordsCopy = oldRecords.stream()
+ .filter(r -> !(r instanceof NSECRecord) && !(r
instanceof RRSIGRecord))
+ .collect(Collectors.toList());
+ final List<Record> newRecordsCopy = newRecords.stream()
+ .filter(r -> !(r instanceof NSECRecord) && !(r
instanceof RRSIGRecord))
+ .collect(Collectors.toList());
+ if (oldRecordsCopy.size() != newRecordsCopy.size()) {
+ return false;
+ }
+ Collections.sort(oldRecordsCopy);
+ Collections.sort(newRecordsCopy);
+ for (int i = 0; i < newRecordsCopy.size(); i++) {
+ final Record newRec = newRecordsCopy.get(i);
+ final Record oldRec = oldRecordsCopy.get(i);
+ if (newRec instanceof SOARecord && oldRec instanceof
SOARecord) {
Review comment:
To me it seems weird to not use `instanceof` when typecasting from Record to
one of its subclasses, and if I'm using it for SOARecord down here I think it
makes sense to use it up above for consistency within this method as well.
Are there performance concerns about using `instanceof`?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services