void handle(DnsResponse msg) { DnsResponseCode code = DnsResponseCode.valueOf(msg.code().intValue()); if (code == DnsResponseCode.NOERROR) { inProgressMap.remove(msg.id()); if (timerID >= 0) { vertx.cancelTimer(timerID); } int count = msg.count(DnsSection.ANSWER); List<T> records = new ArrayList<>(count); for (int idx = 0;idx < count;idx++) { DnsRecord a = msg.recordAt(DnsSection.ANSWER, idx); T record = RecordDecoder.decode(a); if (isRequestedType(a.type(), types)) { records.add(record); } } if (records.size() > 0 && (records.get(0) instanceof MxRecordImpl || records.get(0) instanceof SrvRecordImpl)) { Collections.sort((List) records); } actualCtx.executeFromIO(v -> { fut.tryComplete(records); }); } else { actualCtx.executeFromIO(new DnsException(code), this::fail); } }
void handle(DnsResponse msg) { DnsResponseCode code = DnsResponseCode.valueOf(msg.code().intValue()); if (code == DnsResponseCode.NOERROR) { inProgressMap.remove(msg.id()); if (timerID >= 0) { vertx.cancelTimer(timerID); } int count = msg.count(DnsSection.ANSWER); List<T> records = new ArrayList<>(count); for (int idx = 0;idx < count;idx++) { DnsRecord a = msg.recordAt(DnsSection.ANSWER, idx); T record = RecordDecoder.decode(a); if (isRequestedType(a.type(), types)) { records.add(record); } } if (records.size() > 0 && (records.get(0) instanceof MxRecordImpl || records.get(0) instanceof SrvRecordImpl)) { Collections.sort((List) records); } actualCtx.executeFromIO(v -> { fut.tryComplete(records); }); } else { actualCtx.executeFromIO(new DnsException(code), this::fail); } }