ho sofferto lo stesso problema e quindi mi sono imbattuto in questo nel changelog JSch (http://www.jcraft.com/jsch/ChangeLog):
- funzione: Aggiunto 'Channel.isClosed ()'. Channel.getExitStatus() deve essere invocato dopo Channel.isClosed() == true.
Così bussò questo fino: deve essere chiamato prima channel.disconnect(), altrimenti ancora ottenere -1 problema:
private static void waitForChannelClosure(ChannelExec ce, long maxwaitMs) {
log.info("waitForChannelClosure >>>");
final long until = System.currentTimeMillis() + maxwaitMs;
try {
while (!ce.isClosed() && System.currentTimeMillis() < until) {
log.info("SFTP channel not closed .. waiting");
Thread.sleep(250);
}
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted", e);
}
if (!ce.isClosed()) {
throw new RuntimeException("Channel not closed in timely manner!");
}
};
fonte
2011-12-14 17:02:56
ho anche bruciato da JSch ed è terribile api e i loro documenti: "... e solo dopo che il canale è stato chiuso (più esattamente, appena prima che il canale sia chiuso)." – Tnem