This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
commit e819f5db9daf556b156a56a4703064cfb9471f4e Author: Gary Gregory <[email protected]> AuthorDate: Sat Mar 20 18:13:04 2021 -0400 Trying fix for failing builds on GitHub. --- .../apache/commons/vfs2/provider/sftp/SftpFileObject.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java index f4b4129..79ed0e8 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileObject.java @@ -103,16 +103,17 @@ public class SftpFileObject extends AbstractFileObject<SftpFileSystem> { * @throws IOException */ private void statSelf() throws IOException { - ChannelSftp channel = getAbstractFileSystem().getChannel(); + ChannelSftp channelSftp = null; try { - setStat(channel.stat(relPath)); + channelSftp = getAbstractFileSystem().getChannel(); + setStat(channelSftp.stat(relPath)); } catch (final SftpException e) { try { // maybe the channel has some problems, so recreate the channel and retry if (e.id != ChannelSftp.SSH_FX_NO_SUCH_FILE) { - channel.disconnect(); - channel = getAbstractFileSystem().getChannel(); - setStat(channel.stat(relPath)); + channelSftp.disconnect(); + channelSftp = getAbstractFileSystem().getChannel(); + setStat(channelSftp.stat(relPath)); } else { // Really does not exist attrs = null; @@ -129,7 +130,9 @@ public class SftpFileObject extends AbstractFileObject<SftpFileSystem> { attrs = null; } } finally { - getAbstractFileSystem().putChannel(channel); + if (channelSftp != null) { + getAbstractFileSystem().putChannel(channelSftp); + } } }
