3

This happens on some files but not on others.

1: End of file
        at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
        at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2198)
        at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1294)
        at com.jcraft.jsch.ChannelSftp.get(ChannelSftp.java:1266)

The code is simple:

        jsch.addIdentity("privateKeyFromOdin", sftpPrivateKey, null, null);
        session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT);
        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");
        session.setConfig(config);
        session.connect();
        Channel channel = session.openChannel("sftp");
        channel.connect();
        channelSftp = (ChannelSftp) channel;

        Vector<ChannelSftp.LsEntry> ls = channelSftp.ls(".");
        for (ChannelSftp.LsEntry entry : ls) {
                String fileName = entry.getFilename();
                encryptedStream = channelSftp.get(fileName);//Exception thrown here
        }

What's even more odd is that this used to work well. But I don't know what changed.

Kam
  • 5,878
  • 10
  • 53
  • 97

1 Answers1

3

I had similar issue, I was not closing inputStream returned by each "channelSftp.get(fileName)" call, try closing inputStream

vivek pandey
  • 45
  • 1
  • 8