[JSch-users] Exception in ChannelSession
Status: Alpha
Brought to you by:
ymnk
From: <be...@pr...> - 2006-05-18 09:18:34
|
Hi, sometimes, my application gets a exception in om.jcraft.jsch.ChannelSession.run Line 81. The line in question looks harmless to me: if(thread!=null){ synchronized(thread){ thread.notifyAll(); } } I use blackdown-jdk-1.4.2.03 on Linux 2.6.15 on a 64Bit-Athlon machine running Gentoo. I tried jsch-0.1.28 and jsch-0.1.26. Maybe I do something wrong. I wrote a Wrapper around jsch, the execute function is: public ExecResult execute(String command) throws JSchException, IOException { int channelResult = -99; Channel channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand(command); channel.setInputStream(null); ((ChannelExec) channel).setErrStream(System.err); InputStream in = channel.getInputStream(); ByteArrayOutputStream errOut = new ByteArrayOutputStream(); ByteArrayOutputStream sysOut = new ByteArrayOutputStream(); channel.setOutputStream(sysOut); ((ChannelExec) channel).setErrStream(errOut); channel.connect(); while (true) { if (channel.isClosed()) { channelResult = channel.getExitStatus(); break; } try { Thread.sleep(50); } catch (Exception ee) { } } channel.disconnect(); return new ExecResult( channelResult, sysOut.toString(), errOut.toString()); } If I run a test like the one below, I get about 10 exeptions: public static void main(String[] arg) { String sshhost="netwar"; String sshuser="root"; String sshpassword="0987"; SSHExec sshExec ; try { long l= System.currentTimeMillis(); sshExec = new SSHExec(sshhost,sshuser,sshpassword); System.out.println("got ssh after "+(System.currentTimeMillis()-l)); System.out.println("Connected to "+sshhost+" as "+sshuser); l= System.currentTimeMillis(); for (int i=0;i<1000;i++) { ExecResult er = sshExec.execute("pwd"); System.out.println(i+" "+er.getResultCode()+" "+er.getSysOut()); } } catch (Exception e) { e.printStackTrace(); } } Thanks in advance, Bernd --__--__-- |