This is an automated email from the ASF dual-hosted git repository. twolf pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
The following commit(s) were added to refs/heads/master by this push: new 99a79239e READ default mode in SftpFileSystemProvider.newFileChannel() (#372) 99a79239e is described below commit 99a79239ee5c1212e43e022cab2a6ce887eae3ef Author: Hannes Erven <han...@erven.at> AuthorDate: Sat Jun 3 17:51:13 2023 +0200 READ default mode in SftpFileSystemProvider.newFileChannel() (#372) According to upstream javadoc, the default mode is READ (only) when there is no mode specified. --- .../java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java | 2 +- .../apache/sshd/sftp/client/fs/AbstractSftpFilesSystemSupport.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java index 06f5f300b..9eb9246f7 100644 --- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java +++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/fs/SftpFileSystemProvider.java @@ -579,7 +579,7 @@ public class SftpFileSystemProvider extends FileSystemProvider { throws IOException { Collection<OpenMode> modes = OpenMode.fromOpenOptions(options); if (modes.isEmpty()) { - modes = EnumSet.of(OpenMode.Read, OpenMode.Write); + modes = EnumSet.of(OpenMode.Read); } // TODO: process file attributes SftpPath p = toSftpPath(path); diff --git a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/fs/AbstractSftpFilesSystemSupport.java b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/fs/AbstractSftpFilesSystemSupport.java index 9c71dfb4f..b589ac25c 100644 --- a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/fs/AbstractSftpFilesSystemSupport.java +++ b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/fs/AbstractSftpFilesSystemSupport.java @@ -33,6 +33,7 @@ import java.nio.file.LinkOption; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; import java.nio.file.attribute.AclEntry; import java.nio.file.attribute.AclFileAttributeView; import java.util.Collections; @@ -189,11 +190,11 @@ public abstract class AbstractSftpFilesSystemSupport extends AbstractSftpClientT } protected static void testFileChannelLock(Path file) throws IOException { - try (FileChannel channel = FileChannel.open(file)) { + try (FileChannel channel = FileChannel.open(file, StandardOpenOption.WRITE)) { try (FileLock lock = channel.lock()) { outputDebugMessage("Lock %s: %s", file, lock); - try (FileChannel channel2 = FileChannel.open(file)) { + try (FileChannel channel2 = FileChannel.open(file, StandardOpenOption.WRITE)) { try (FileLock lock2 = channel2.lock()) { fail("Unexpected success in re-locking " + file + ": " + lock2); } catch (OverlappingFileLockException e) {