je souffrais le même problème et suis tombé sur ce dans le changelog jsch (http://www.jcraft.com/jsch/ChangeLog):
- fonction: ajoutée « Channel.isClosed () '. Channel.getExitStatus() doit être invoqué après Channel.isClosed() == true.
donc frappé cette place: doit être appelée avant channel.disconnect(), sinon obtenir encore -1 question:
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!");
}
};
J'ai aussi été brûlé par JSch et il est terrible api et leurs docs: "... et seulement après la fermeture du canal (plus exactement, juste avant la fermeture du canal)". – Tnem