当前位置: 首页>>代码示例>>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;未经允许,请勿转载。