[SSHD-667] RootedFileSystemProvider throws ProviderMismatchException when calling newByteChannel
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 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
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 @@
 
 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 @@
         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 */