Commit 0d5d5867 authored by Tom Evans's avatar Tom Evans

OF-2: Logging for common exceptions less verbose

Modified older patch submitted by David Horowitz to accommodate more
recent changes.
parent 4a809ace
......@@ -24,6 +24,8 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
......@@ -270,18 +272,24 @@ public class LocalOutgoingServerSession extends LocalSession implements Outgoing
List<DNSUtil.HostAddress> hosts = DNSUtil.resolveXMPPDomain(hostname, port);
for (Iterator<DNSUtil.HostAddress> it = hosts.iterator(); it.hasNext();) {
try {
socket = new Socket();
DNSUtil.HostAddress address = it.next();
realHostname = address.getHost();
realPort = address.getPort();
Log.debug("LocalOutgoingServerSession: OS - Trying to connect to " + hostname + ":" + port +
"(DNS lookup: " + realHostname + ":" + realPort + ")");
// Establish a TCP connection to the Receiving Server
socket.connect(new InetSocketAddress(realHostname, realPort),
RemoteServerManager.getSocketTimeout());
socket = new Socket();
socket.connect(new InetSocketAddress(realHostname, realPort), RemoteServerManager.getSocketTimeout());
Log.debug("LocalOutgoingServerSession: OS - Plain connection to " + hostname + ":" + port + " successful");
break;
}
catch (UnknownHostException uhe) {
Log.warn("Unkown host: " + realHostname);
}
catch (SocketTimeoutException ste) {
Log.error("Connection Timeed out trying to connect to remote server: " + hostname +
"(DNS lookup: " + realHostname + ":" + realPort + ")");
}
catch (Exception e) {
Log.warn("Error trying to connect to remote server: " + hostname +
"(DNS lookup: " + realHostname + ":" + realPort + ")", e);
......@@ -295,7 +303,7 @@ public class LocalOutgoingServerSession extends LocalSession implements Outgoing
}
}
}
if (!socket.isConnected()) {
if (socket == null || !socket.isConnected()) {
return null;
}
......@@ -374,32 +382,27 @@ public class LocalOutgoingServerSession extends LocalSession implements Outgoing
Log.debug("LocalOutgoingServerSession: OS - Error, <starttls> was not received");
}
}
// Something went wrong so close the connection and try server dialback over
// a plain connection
if (connection != null) {
connection.close();
}
}
catch (SSLHandshakeException e) {
Log.debug("LocalOutgoingServerSession: Handshake error while creating secured outgoing session to remote " +
"server: " + hostname + "(DNS lookup: " + realHostname + ":" + realPort +
")", e);
// Close the connection
if (connection != null) {
connection.close();
}
Log.debug("LocalOutgoingServerSession: SSL Handshake error while creating secured outgoing session to remote " +
"server: " + hostname + "(DNS lookup: " + realHostname + ":" + realPort + "): " + e.getMessage());
}
catch (XmlPullParserException e) {
Log.warn("Error creating secured outgoing session to remote server: " + hostname +
"(DNS lookup: " + realHostname + ":" + realPort + ")", e);
// Close the connection
if (connection != null) {
connection.close();
"(DNS lookup: " + realHostname + ":" + realPort + "): ", e);
}
catch (UnknownHostException uhe) {
Log.warn("Unkown host: " + realHostname);
}
catch (SocketTimeoutException ste) {
Log.error("Connection Timeed out trying to connect to remote server: " + hostname +
"(DNS lookup: " + realHostname + ":" + realPort + ")");
}
catch (Exception e) {
Log.error("Error creating secured outgoing session to remote server: " + hostname +
"(DNS lookup: " + realHostname + ":" + realPort + ")", e);
}
finally {
// Close the connection
if (connection != null) {
connection.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment