chibenwa commented on code in PR #3211:
URL: https://github.com/apache/james-project/pull/3211#discussion_r4119297094


##########
server/dns-service/dnsservice-dnsjava/src/main/java/org/apache/james/dnsservice/dnsjava/DNSJavaService.java:
##########
@@ -315,25 +315,26 @@ private List<String> findMXRecordsRaw(String hostname) 
throws TemporaryResolutio
     @Override
     public Collection<String> findMXRecords(String hostname) throws 
TemporaryResolutionException {
         TimeMetric timeMetric = metricFactory.timer("findMXRecords");
-        List<String> servers = new ArrayList<>();
         try {
-            servers = findMXRecordsRaw(hostname);
-            return Collections.unmodifiableCollection(servers);
-        } finally {
+            List<String> servers = findMXRecordsRaw(hostname);
+            if (!servers.isEmpty()) {
+                return Collections.unmodifiableCollection(servers);
+            }
+
             // If we found no results, we'll add the original domain name if
             // it's a valid DNS entry
-            if (servers.isEmpty()) {
-                LOGGER.info("Couldn't resolve MX records for domain {}.", 
hostname);
-                try {
-                    getByName(hostname);
-                    servers.add(hostname);
-                } catch (UnknownHostException uhe) {
-                    // The original domain name is not a valid host,
-                    // so we can't add it to the server list. In this
-                    // case we return an empty list of servers
-                    LOGGER.error("Couldn't resolve IP address for host {}.", 
hostname, uhe);
-                }
+            LOGGER.info("Couldn't resolve MX records for domain {}.", 
hostname);

Review Comment:
   ```suggestion
               LOGGER.info("Couldn't resolve MX records for domain {}. Falling 
back to A/AAAA resolution instead", hostname);
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to