Small improvement

pull/178/head
M66B 5 years ago
parent 254364d29a
commit 7e6097bcf2

@ -363,13 +363,17 @@ public class EmailService implements AutoCloseable {
private void connect( private void connect(
String host, int port, String user, String password, String host, int port, String user, String password,
SSLSocketFactoryService factory) throws MessagingException { SSLSocketFactoryService factory) throws MessagingException {
InetAddress main = null;
try { try {
//if (BuildConfig.DEBUG) //if (BuildConfig.DEBUG)
// throw new MailConnectException( // throw new MailConnectException(
// new SocketConnectException("Debug", new IOException("Test"), host, port, 0)); // new SocketConnectException("Debug", new IOException("Test"), host, port, 0));
EntityLog.log(context, "Connecting to " + host); main = InetAddress.getByName(host);
_connect(host, port, user, password, factory); EntityLog.log(context, "Connecting to " + main);
_connect(main.getHostAddress(), port, user, password, factory);
} catch (UnknownHostException ex) {
throw new MessagingException(ex.getMessage(), ex);
} catch (MessagingException ex) { } catch (MessagingException ex) {
boolean ioError = false; boolean ioError = false;
Throwable ce = ex; Throwable ce = ex;
@ -385,7 +389,6 @@ public class EmailService implements AutoCloseable {
EntityLog.log(context, "Connect ex=" + ex.getMessage()); EntityLog.log(context, "Connect ex=" + ex.getMessage());
try { try {
// Some devices resolve IPv6 addresses while not having IPv6 connectivity // Some devices resolve IPv6 addresses while not having IPv6 connectivity
InetAddress main = InetAddress.getByName(host);
InetAddress[] iaddrs = InetAddress.getAllByName(host); InetAddress[] iaddrs = InetAddress.getAllByName(host);
boolean ip4 = (main instanceof Inet4Address); boolean ip4 = (main instanceof Inet4Address);
boolean ip6 = (main instanceof Inet6Address); boolean ip6 = (main instanceof Inet6Address);
@ -431,7 +434,7 @@ public class EmailService implements AutoCloseable {
} }
try { try {
EntityLog.log(context, "Falling back to " + iaddr.getHostAddress()); EntityLog.log(context, "Falling back to " + iaddr);
_connect(iaddr.getHostAddress(), port, user, password, factory); _connect(iaddr.getHostAddress(), port, user, password, factory);
return; return;
} catch (MessagingException ex1) { } catch (MessagingException ex1) {

Loading…
Cancel
Save