當前位置: 首頁>>代碼示例>>Java>>正文


Java JSchException.getCause方法代碼示例

本文整理匯總了Java中com.jcraft.jsch.JSchException.getCause方法的典型用法代碼示例。如果您正苦於以下問題:Java JSchException.getCause方法的具體用法?Java JSchException.getCause怎麽用?Java JSchException.getCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.jcraft.jsch.JSchException的用法示例。


在下文中一共展示了JSchException.getCause方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import com.jcraft.jsch.JSchException; //導入方法依賴的package包/類
public JSch build() throws JSchException {
    LOGGER.debug("Initializing JSch Logger");
    JSch.setLogger(new JschLogger());
    final JSch jsch = new JSch();
    try {
        if (null != knownHostsFileName && new File(knownHostsFileName).exists()) {
            jsch.setKnownHosts(knownHostsFileName);
        }
        if (null != privateKeyFileName && new File(privateKeyFileName).exists()) {
            jsch.addIdentity(privateKeyFileName);
        }
    } catch (JSchException e) {
        LOGGER.error("Could not access known hosts or private key file.", e);
        if (!(e.getCause() instanceof FileNotFoundException)) {
            throw new JSchException();
        }
    }
    return jsch;
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:20,代碼來源:JschBuilder.java

示例2: start

import com.jcraft.jsch.JSchException; //導入方法依賴的package包/類
private synchronized static ChannelStreams start(final JSchWorker<ChannelStreams> worker, final ExecutionEnvironment env, final int attempts) throws IOException, JSchException, InterruptedException {
    int retry = attempts;

    while (retry-- > 0) {
        try {
            return worker.call();
        } catch (JSchException ex) {
            String message = ex.getMessage();
            Throwable cause = ex.getCause();
            if (cause != null && cause instanceof NullPointerException) {
                // Jsch bug... retry?
                log.log(Level.INFO, "JSch exception opening channel to " + env + ". Retrying", ex); // NOI18N
            } else if ("java.io.InterruptedIOException".equals(message)) { // NOI18N
                log.log(Level.INFO, "JSch exception opening channel to " + env + ". Retrying in 0.5 seconds", ex); // NOI18N
                try {
                    Thread.sleep(500);
                } catch (InterruptedException ex1) {
                    Thread.currentThread().interrupt();
                    break;
                }
            } else if ("channel is not opened.".equals(message)) { // NOI18N
                log.log(Level.INFO, "JSch exception opening channel to " + env + ". Reconnecting and retrying", ex); // NOI18N
                // Now reconnect disconnects old session and creates new, so this might help
                ConnectionManagerAccessor.getDefault().reconnect(env);

            } else {
                throw ex;
            }
        } catch (NullPointerException npe) {
            // Jsch bug... retry? ;)
            log.log(Level.FINE, "Exception from JSch", npe); // NOI18N
        }
    }

    throw new IOException("Failed to execute " + worker.toString()); // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:JschSupport.java


注:本文中的com.jcraft.jsch.JSchException.getCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。