public CoreRemotingConnection getConnection()
{
if (connection == null)
{
Connection tc = null;
try
{
DelegatingBufferHandler handler = new DelegatingBufferHandler();
connector = connectorFactory.createConnector(transportParams,
handler,
this,
closeExecutor,
threadPool,
scheduledThreadPool);
if (connector != null)
{
connector.start();
tc = connector.createConnection();
if (tc == null)
{
try
{
connector.close();
}
catch (Throwable t)
{
}
connector = null;
}
}
}
catch (Exception e)
{
// Sanity catch for badly behaved remoting plugins
FailoverManagerImpl.log.warn("connector.create or connectorFactory.createConnector should never throw an exception, implementation is badly behaved, but we'll deal with it anyway.",
e);
if (tc != null)
{
try
{
tc.close();
}
catch (Throwable t)
{
}
}