Skip to content

Commit

Permalink
[VFS-726]getInputStream(int bufferSize) on SftpFileObject effectively ig
Browse files Browse the repository at this point in the history
nores buffer size.
  • Loading branch information
Gary Gregory committed Aug 16, 2019
1 parent 5aaa0b5 commit 953aa40
Show file tree
Hide file tree
Showing 21 changed files with 6,149 additions and 6,069 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3,759 changes: 1,894 additions & 1,865 deletions commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/AbstractFileObject.java

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -52,9 +52,9 @@ protected Bzip2FileObject(final AbstractFileName name, final FileObject containe
}

@Override
protected InputStream doGetInputStream() throws Exception {
protected InputStream doGetInputStream(final int bufferSize) throws Exception {
// check file
final InputStream is = getContainer().getContent().getInputStream();
final InputStream is = getContainer().getContent().getInputStream(bufferSize);
return wrapInputStream(getName().getURI(), is);
}

Expand Down
Expand Up @@ -250,6 +250,20 @@ public InputStream retrieveFileStream(final String relPath) throws IOException {
}
}

@Override
public InputStream retrieveFileStream(final String relPath, final int bufferSize) throws IOException {
try {
final FTPClient client = getFtpClient();
client.setBufferSize(bufferSize);
return client.retrieveFileStream(relPath);
} catch (final IOException e) {
disconnect();
final FTPClient client = getFtpClient();
client.setBufferSize(bufferSize);
return client.retrieveFileStream(relPath);
}
}

@Override
public InputStream retrieveFileStream(final String relPath, final long restartOffset) throws IOException {
try {
Expand All @@ -264,6 +278,11 @@ public InputStream retrieveFileStream(final String relPath, final long restartOf
}
}

@Override
public void setBufferSize(final int bufferSize) throws FileSystemException {
getFtpClient().setBufferSize(bufferSize);
}

@Override
public OutputStream storeFileStream(final String relPath) throws IOException {
try {
Expand Down
Expand Up @@ -57,8 +57,17 @@ default int getReplyCode() throws IOException {

InputStream retrieveFileStream(String relPath) throws IOException;

default InputStream retrieveFileStream(String relPath, int bufferSize) throws IOException {
// Backward compatibility: no buffer size.
return retrieveFileStream(relPath);
}

InputStream retrieveFileStream(String relPath, long restartOffset) throws IOException;

default void setBufferSize(int bufferSize) throws FileSystemException {
// Backward compatibility: do nothing.
}

OutputStream storeFileStream(String relPath) throws IOException;

}

0 comments on commit 953aa40

Please sign in to comment.