Skip to content

Commit c0308df

Browse files
committed
When connection is having problem, closing remoteFile will make the thread stalling
1 parent 91a4a63 commit c0308df

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/java/org/embulk/output/sftp/SftpUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,11 @@ public Void call() throws Exception
160160
final BufferedOutputStream outputStream = openStream(remoteFile);
161161
// When channel is broken, closing resource may hang, hence the time-out wrapper
162162
// Note: closing FileObject will also close OutputStream
163-
try (TimeoutCloser ignored = new TimeoutCloser(outputStream)) {
163+
try (final TimeoutCloser ignored1 = new TimeoutCloser(outputStream);
164+
final TimeoutCloser ignored2 = new TimeoutCloser(remoteFile)) {
164165
appendFile(localTempFile, remoteFile, outputStream);
165166
return null;
166167
}
167-
finally {
168-
remoteFile.close();
169-
}
170168
}
171169
});
172170
}

0 commit comments

Comments
 (0)