private void informConnectListener(Channel channel, Throwable cause) {
boolean success = (cause == null);
_log.debug("informRequestListener: success=" + success + ";ch=" + channel, cause);
// listener is nullified (under sync) to guarantee it is called only once
ConnectResultListener tempListener = null;
synchronized(this) {
if(cause != null)
_lastError = cause;
if(_connectListener != null) {
tempListener = _connectListener;
_connectListener = null;
}
}
if(tempListener != null) {
_log.info("Notify about connection completed. success=" + success);
if(success)
tempListener.onConnectSuccess(channel);
else
tempListener.onConnectFailure(cause);
} else {
_log.warn("informConnectListener called with listener==null; ch=" + channel, cause);
}
}