fix failing multithreaded SshClient#connect

2009-01-28
2014-12-04
  • Guillaume Cottenceau

    There is changing of shared (static) data when invoking SshClient#connect, because SshCipherFactory#getSupportCiphers doesn't copy the returned list (as other similar calls from SshMsgKexInit#<init> do). Here's a patch, and follows the exception I received because of that bug.

    --- src/com/sshtools/j2ssh/transport/cipher/SshCipherFactory.java    2007-04-28 21:02:54.000000000 +0200
    +++ src/com/sshtools/j2ssh/transport/cipher/SshCipherFactory.java    2009-01-28 14:15:25.000000000 +0100
    @@ -139,7 +139,7 @@
          */
         public static List getSupportedCiphers() {
             // Return the list
    -        return supported;
    +        return new ArrayList(supported);
         }

         /**

    The exception:

    ERROR [Transport protocol 4] TransportProtocolCommon:?(run) - The Transport Protocol thread failed
    java.lang.ArrayIndexOutOfBoundsException
            at java.lang.System.arraycopy(Native Method)
            at java.util.ArrayList.add(ArrayList.java:372)
            at com.sshtools.j2ssh.transport.SshMsgKexInit.sortAlgorithmList(Unknown Source)
            at com.sshtools.j2ssh.transport.SshMsgKexInit.<init>(Unknown Source)
            at com.sshtools.j2ssh.transport.TransportProtocolCommon.createLocalKexInit(Unknown Source)
            at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendKeyExchangeInit(Unknown Source)
            at com.sshtools.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol(Unknown Source)
            at com.sshtools.j2ssh.transport.TransportProtocolCommon.run(Unknown Source)
            at java.lang.Thread.run(Thread.java:595)

    triggering

    SFTP connection failure: exception: com.sshtools.j2ssh.transport.TransportProtocolException: The connection did not complete at:
            com.sshtools.j2ssh.transport.TransportProtocolClient.onStartTransportProtocol(Unknown Source)
            com.sshtools.j2ssh.transport.TransportProtocolCommon.startTransportProtocol(Unknown Source)
            com.sshtools.j2ssh.SshClient.connect(Unknown Source)

     
    • Luca D'Andria

      Luca D'Andria - 2014-12-04

      I just wanted to say thank you for this. I found this exception and was puzzled on what could cause it and how to solve it. A really tricky bug that I was able to fix recompiling with the patch just like you indicated. Thanks a lot!

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks