Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READ (only) default mode in SftpFileSystemProvider.newFileChannel() #372

Merged
merged 1 commit into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -189,11 +190,11 @@ protected static void testSymbolicLinks(Path link, Path relPath) throws IOExcept
}

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) {
Expand Down