shikhar/sshj — Issue #64: Upload file succeeds but raises IOException
Author: haydarekarrar
Created: 2012-03-02 15:08:01+00:00
State: open

When uploading a file through

```
ftp.getFileTransfer().upload(filePath, ".");
```

The file is transferred to the server but raises an IOException, probably due to some EOF.

Complete LOG :

```
2012-03-02 15:08:52 Trying to register BouncyCastle as a JCE provider
2012-03-02 15:08:54 Registration succeeded
2012-03-02 15:08:55 Disabling high-strength ciphers: cipher strengths apparently limited by JCE policy
2012-03-02 15:08:55 Client identity string: SSH-2.0-SSHJ_0_8
2012-03-02 15:08:55 Server identity string: SSH-2.0-mod_sftp/0.9.7
2012-03-02 15:08:55 Setting <> to `null`
2012-03-02 15:08:55 Received SSH_MSG_KEXINIT
2012-03-02 15:08:55 Sending SSH_MSG_KEXINIT
2012-03-02 15:08:55 Awaiting <>
2012-03-02 15:08:55 Setting <> to `SOME`
2012-03-02 15:08:55 Awaiting <>
2012-03-02 15:08:55 Negotiated algorithms: [ kex=diffie-hellman-group14-sha1; sig=ssh-rsa; c2sCipher=aes128-ctr; s2cCipher=aes128-ctr; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none ]
2012-03-02 15:08:55 Sending SSH_MSG_KEXDH_INIT
2012-03-02 15:08:55 Received kex followup data
2012-03-02 15:08:55 Received SSH_MSG_KEXDH_REPLY
2012-03-02 15:08:55 Trying to verify host key with net.schmizz.sshj.SSHClient$1@272c3a87
2012-03-02 15:08:55 Sending SSH_MSG_NEWKEYS
2012-03-02 15:08:55 Received SSH_MSG_NEWKEYS
2012-03-02 15:08:55 Setting <> to `null`
2012-03-02 15:08:55 Setting <> to `SOME`
2012-03-02 15:08:55 Key exchange took 0.277 seconds
2012-03-02 15:08:55 Setting <> to `null`
2012-03-02 15:08:55 Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth
2012-03-02 15:08:55 Awaiting <>
2012-03-02 15:08:55 Setting <> to `SOME`
2012-03-02 15:08:55 Setting active service to ssh-userauth
2012-03-02 15:08:55 Trying `password` auth...
2012-03-02 15:08:55 Setting <> to `null`
2012-03-02 15:08:55 Requesting password for [AccountResource] server@theeeserver
2012-03-02 15:08:55 Awaiting <>
2012-03-02 15:08:55 Setting <> to `SOME`
2012-03-02 15:08:55 `password` auth successful
2012-03-02 15:08:55 Setting active service to ssh-connection
2012-03-02 15:08:55 Attaching `session` channel (#0)
2012-03-02 15:08:56 Awaiting <>
2012-03-02 15:08:56 Initialized - < session channel: id=0, recipient=0, localWin=[winSize=2097152], remoteWin=[winSize=4294967295] >
2012-03-02 15:08:56 Setting <> to `SOME`
2012-03-02 15:08:56 Will request `sftp` subsystem
2012-03-02 15:08:56 Sending channel request for `subsystem`
2012-03-02 15:08:56 Awaiting <>
2012-03-02 15:08:56 Setting <> to `SOME`
2012-03-02 15:08:56 Consuming by 9 down to 4294967286
2012-03-02 15:08:56 Consuming by 124 down to 2097028
2012-03-02 15:08:56 Server version 3
2012-03-02 15:09:03 started transferring file `2012-Mar-2` (188 bytes)
2012-03-02 15:09:03 Sending Request{1;STAT}
2012-03-02 15:09:03 Consuming by 14 down to 4294967272
2012-03-02 15:09:03 Awaiting <>
2012-03-02 15:09:03 Consuming by 41 down to 2096987
2012-03-02 15:09:03 Received ATTRS packet
2012-03-02 15:09:03 Setting <> to `Buffer [rpos=5, wpos=37, size=37]`
2012-03-02 15:09:03 probeFile: . was directory, path adjusted for 2012-Mar-2
2012-03-02 15:09:03 Sending Request{2;OPEN}
2012-03-02 15:09:03 Consuming by 33 down to 4294967239
2012-03-02 15:09:03 Awaiting <>
2012-03-02 15:09:04 Consuming by 19 down to 2096968
2012-03-02 15:09:04 Received HANDLE packet
2012-03-02 15:09:04 Setting <> to `Buffer [rpos=5, wpos=15, size=15]`
2012-03-02 15:09:04 Sending Request{3;WRITE}
2012-03-02 15:09:04 Consuming by 219 down to 4294967020
2012-03-02 15:09:04 Awaiting <>
2012-03-02 15:09:04 Consuming by 28 down to 2096940
2012-03-02 15:09:04 Received STATUS packet
2012-03-02 15:09:04 Setting <> to `Buffer [rpos=5, wpos=24, size=24]`
2012-03-02 15:09:04 transferred 100% of `2012-Mar-2`
2012-03-02 15:09:04 0.18359375 KiB transferred in 0.066 seconds (2.781723484848485 KiB/s)
2012-03-02 15:09:04 Closing `RemoteResource{./2012-Mar-2}`
2012-03-02 15:09:04 Sending Request{4;CLOSE}
2012-03-02 15:09:04 Consuming by 19 down to 4294967001
2012-03-02 15:09:04 Awaiting <>
2012-03-02 15:09:04 Consuming by 28 down to 2096912
2012-03-02 15:09:04 Received STATUS packet
2012-03-02 15:09:04 Setting <> to `Buffer [rpos=5, wpos=24, size=24]`
2012-03-02 15:09:04 Sending Request{5;SETSTAT}
2012-03-02 15:09:04 Consuming by 41 down to 4294966960
2012-03-02 15:09:04 Awaiting <>
2012-03-02 15:09:04 Consuming by 38 down to 2096874
2012-03-02 15:09:04 Received STATUS packet
2012-03-02 15:09:04 Setting <> to `Buffer [rpos=5, wpos=34, size=34]`
2012-03-02 15:09:06 Sending close
2012-03-02 15:09:06 Awaiting <>
2012-03-02 15:09:06 Got chan request for `exit-status`
2012-03-02 15:09:06 Got EOF
2012-03-02 15:09:06 Got close
2012-03-02 15:09:06 Forgetting `session` channel (#0)
2012-03-02 15:09:06 Setting <> to `SOME`
```

Stack trace

```
net.schmizz.sshj.sftp.SFTPException: No such file
at net.schmizz.sshj.sftp.Response.error(Response.java:113)
at net.schmizz.sshj.sftp.Response.ensureStatusIs(Response.java:106)
at net.schmizz.sshj.sftp.Response.ensureStatusPacketIsOK(Response.java:99)
at net.schmizz.sshj.sftp.SFTPEngine.setAttributes(SFTPEngine.java:149)
at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.upload(SFTPFileTransfer.java:176)
at net.schmizz.sshj.sftp.SFTPFileTransfer$Uploader.access$100(SFTPFileTransfer.java:163)
at net.schmizz.sshj.sftp.SFTPFileTransfer.upload(SFTPFileTransfer.java:61)
at net.schmizz.sshj.sftp.SFTPFileTransfer.upload(SFTPFileTransfer.java:49)
```

Not so sure about that "No such file" message.