You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/05/17 16:33:10 UTC

mina-sshd git commit: [SSHD-667] RootedFileSystemProvider throws ProviderMismatchException when calling newByteChannel

Repository: mina-sshd
Updated Branches:
  refs/heads/master 8efd018f2 -> d352e9c0c


[SSHD-667] RootedFileSystemProvider throws ProviderMismatchException when calling newByteChannel


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/d352e9c0
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/d352e9c0
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/d352e9c0

Branch: refs/heads/master
Commit: d352e9c0c12f8bd8174a3bf6f2e69b82c42bf3d8
Parents: 8efd018
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Tue May 17 19:33:49 2016 +0300
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Tue May 17 19:33:49 2016 +0300

----------------------------------------------------------------------
 .../sshd/common/file/root/RootedFileSystemProvider.java |  2 +-
 .../common/file/root/RootedFileSystemProviderTest.java  | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d352e9c0/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
index ff693a1..3caa4f6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
@@ -184,7 +184,7 @@ public class RootedFileSystemProvider extends FileSystemProvider {
     public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
         Path r = unroot(path);
         FileSystemProvider p = provider(r);
-        return p.newByteChannel(path, options, attrs);
+        return p.newByteChannel(r, options, attrs);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d352e9c0/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
index dd1fcbb..32131c3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
@@ -21,8 +21,10 @@ package org.apache.sshd.common.file.root;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.channels.Channel;
 import java.nio.channels.FileChannel;
 import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
 import java.nio.file.Files;
 import java.nio.file.InvalidPathException;
 import java.nio.file.OpenOption;
@@ -210,6 +212,16 @@ public class RootedFileSystemProviderTest extends AssertableFile {
         Path link = FileHelper.createLink(fileSystem.getPath("../" + getCurrentTestName() + "link"), existing);
         fail(String.format("Unexpected success in linking file %s", link.toString()));
     }
+    @Test
+    public void testNewByteChannelProviderMismatchException() throws IOException {
+        RootedFileSystemProvider provider = new RootedFileSystemProvider();
+        Path tempFolder = assertHierarchyTargetFolderExists(getTempTargetFolder());
+        Path file = Files.createTempFile(tempFolder, getCurrentTestName(), ".txt");
+        try (FileSystem fs = provider.newFileSystem(tempFolder, Collections.<String, Object>emptyMap());
+             Channel channel = provider.newByteChannel(fs.getPath(file.getFileName().toString()), Collections.<OpenOption>emptySet())) {
+            assertTrue("Channel not open", channel.isOpen());
+        }
+    }
 
     /* Private helper */