don't close underlying RemoteFile when closing streams of that file - reverts f34667521d

This commit is contained in:
shikhar
2014-06-24 14:20:04 +05:30
parent 0a3ad4f68f
commit 0875417dde

View File

@@ -15,6 +15,10 @@
*/
package net.schmizz.sshj.sftp;
import net.schmizz.concurrent.Promise;
import net.schmizz.sshj.common.Buffer;
import net.schmizz.sshj.sftp.Response.StatusCode;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -22,10 +26,6 @@ import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import net.schmizz.concurrent.Promise;
import net.schmizz.sshj.common.Buffer;
import net.schmizz.sshj.sftp.Response.StatusCode;
public class RemoteFile
extends RemoteResource {
@@ -62,7 +62,8 @@ public class RemoteFile
return requester.request(newRequest(PacketType.READ).putUInt64(fileOffset).putUInt32(len));
}
protected int checkReadResponse(Response res, byte[] to, int offset) throws Buffer.BufferException, SFTPException {
protected int checkReadResponse(Response res, byte[] to, int offset)
throws Buffer.BufferException, SFTPException {
switch (res.getType()) {
case DATA:
int recvLen = res.readUInt32AsInt();
@@ -166,8 +167,6 @@ public class RemoteFile
public void close()
throws IOException {
flush();
// Close handle
RemoteFile.this.close();
}
}
@@ -256,7 +255,8 @@ public class RemoteFile
}
@Override
public void close() throws IOException {
public void close()
throws IOException {
while (!unconfirmedReads.isEmpty()) {
final Response res = unconfirmedReads.remove().retrieve(
requester.getTimeoutMs(), TimeUnit.MILLISECONDS);
@@ -271,8 +271,6 @@ public class RemoteFile
throw new SFTPException("Unexpected packet: " + res.getType());
}
}
// Close handle
RemoteFile.this.close();
}
}
}