当前位置: 首页>>代码示例>>Java>>正文


Java JSchException.getMessage方法代码示例

本文整理汇总了Java中com.jcraft.jsch.JSchException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java JSchException.getMessage方法的具体用法?Java JSchException.getMessage怎么用?Java JSchException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jcraft.jsch.JSchException的用法示例。


在下文中一共展示了JSchException.getMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupJSch

import com.jcraft.jsch.JSchException; //导入方法依赖的package包/类
private boolean setupJSch (FS fs, String host, CredentialItem.StringType identityFile, URIish uri, boolean preferAgent) throws TransportException {
    boolean agentUsed;
    if (sshConfig == null) {
        sshConfig = OpenSshConfig.get(fs);
    }
    final OpenSshConfig.Host hc = sshConfig.lookup(host);
    try {
        JSch jsch = getJSch(hc, fs);
        agentUsed = setupJSchIdentityRepository(jsch, identityFile.getValue(), preferAgent);
    } catch (JSchException ex) {
        throw new TransportException(uri, ex.getMessage(), ex);
    }
    return agentUsed;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JGitSshSessionFactory.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

示例3: startNewSession

import com.jcraft.jsch.JSchException; //导入方法依赖的package包/类
private Session startNewSession(boolean acquireChannel) throws JSchException, InterruptedException {
    Session newSession = null;
    final AtomicBoolean cancelled = new AtomicBoolean(false);

    ConnectingProgressHandle.startHandle(env, new Cancellable() {
        @Override
        public boolean cancel() {
            cancelled.set(true);
            return true;
        }
    });

    try {
        while (!cancelled.get()) {
            try {
                newSession = jsch.getSession(env.getUser(), env.getHostAddress(), env.getSSHPort());
                int serverAliveInterval = Integer.getInteger("jsch.server.alive.interval", 0); // NOI18N
                if (serverAliveInterval > 0) {
                    newSession.setServerAliveInterval(serverAliveInterval);
                    int serverAliveCount = Integer.getInteger("jsch.server.alive.count", 5); // NOI18N
                    newSession.setServerAliveCountMax(serverAliveCount);
                }
                newSession.setUserInfo(userInfo);

                for (Entry<String, String> entry : jschSessionConfig.entrySet()) {
                    newSession.setConfig(entry.getKey(), entry.getValue());
                }
                Authentication auth = Authentication.getFor(env);
                final String preferredAuthKey = "PreferredAuthentications"; // NOI18N
                if (!jschSessionConfig.containsKey(preferredAuthKey)) {
                    String methods = auth.getAuthenticationMethods().toJschString();
                    if (methods != null) {
                        log.finest("Setting auth method list to " + methods); //NOI18N
                        newSession.setConfig(preferredAuthKey, methods);
                    }
                }
                if (USE_JZLIB) {
                    newSession.setConfig("compression.s2c", "[email protected],zlib,none"); // NOI18N
                    newSession.setConfig("compression.c2s", "[email protected],zlib,none"); // NOI18N
                    newSession.setConfig("compression_level", "9"); // NOI18N
                }

                if (RemoteStatistics.COLLECT_STATISTICS && RemoteStatistics.COLLECT_TRAFFIC) {
                    newSession.setSocketFactory(MeasurableSocketFactory.getInstance());
                }

                newSession.connect(auth.getTimeout()*1000);
                break;
            } catch (JSchException ex) {
                if (!UNIT_TEST_MODE) {
                    String msg = ex.getMessage();
                    if (msg == null) {
                        throw ex;
                    }
                    if (msg.startsWith("Auth fail") || msg.startsWith("SSH_MSG_DISCONNECT: 2")) { // NOI18N
                        PasswordManager.getInstance().clearPassword(env);
                    }
                } else {
                    throw ex;
                }
            } catch (CancellationException cex) {
                cancelled.set(true);
            }
        }

        if (cancelled.get()) {
            throw new InterruptedException("StartNewSession was cancelled ..."); // NOI18N
        }

        // In case of any port-forwarding previously set for this env
        // init the new session appropriately
        portForwarding.initSession(newSession);

        sessions.put(newSession, new AtomicInteger(JSCH_CHANNELS_PER_SESSION - (acquireChannel ? 1 : 0)));

        log.log(Level.FINE, "New session [{0}] started.", new Object[]{System.identityHashCode(newSession)}); // NOI18N
    } finally {
        ConnectingProgressHandle.stopHandle(env);
    }
    return newSession;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:82,代码来源:JSchChannelsSupport.java


注:本文中的com.jcraft.jsch.JSchException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。