if (mySocket == null || isStale()) {
SVNURL location = myRepository.getLocation(); if (mySocket == null || SVNSocketFactory.isSocketStale(mySocket, location)) {
    private void connect() throws SVNException {        if (mySocket == null || isStale()) {            close();            String host = mySVNRepositoryLocation.getHost();            int port = mySVNRepositoryLocation.getPort();            ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();            myProxyAuth = authManager != null ? authManager.getProxyManager(mySVNRepositoryLocation) : null;            ISVNSSLManager sslManager = authManager != null && isSecured() ? authManager.getSSLManager(mySVNRepositoryLocation) : null;            if (myProxyAuth != null && myProxyAuth.getProxyHost() != null) {                mySocket = SVNSocketFactory.createPlainSocket(myProxyAuth.getProxyHost(), myProxyAuth.getProxyPort());                if (isSecured()) {                    Map props = new HashMap();                    if (myProxyAuth.getProxyUserName() != null && myProxyAuth.getProxyPassword() != null) {                        props.put("Proxy-Authorization", getProxyAuthString(myProxyAuth.getProxyUserName(), myProxyAuth.getProxyPassword()));                    }                    DAVStatus status = null;                    try {                        myOutputStream = SVNDebugLog.createLogStream(mySocket.getOutputStream());                        sendHeader("CONNECT", mySVNRepositoryLocation.getHost() + ":" + mySVNRepositoryLocation.getPort(), props, null);                        myOutputStream.flush();                        status = readHeader(new HashMap());                        if (status != null && status.getResponseCode() == 200) {                            myInputStream = null;                            myOutputStream = null;                            mySocket = SVNSocketFactory.createSSLSocket(sslManager, host, port, mySocket);                            return;                        }                    } catch (IOException e) {                        SVNErrorManager.error("svn: Cannot establish connection to proxy server: '" + e.getMessage() + "'");                    }                    SVNErrorManager.error("svn: Cannot establish http tunnel for proxied secure connection: " + (status != null ? status.getErrorText() + "" : " for unknow reason"));                }            } else {                mySocket = isSecured() ? SVNSocketFactory.createSSLSocket(sslManager, host, port) : SVNSocketFactory.createPlainSocket(host, port);            }        }    }