File: handling_FileStore.patch

package info (click to toggle)
libmina-sshd-java 2.13.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,428 kB
  • sloc: java: 136,607; xml: 4,544; sh: 917; python: 239; makefile: 2
file content (70 lines) | stat: -rw-r--r-- 3,931 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Description: loopiing over available FileStore's instead of using
 java.nio.file.Files.getFileStore(Path) in a test, which leads to build
 failures on Debian buildds under certain conditions
Author: Pierre Gruet <pgt@debian.org>
Bug-Debian: https://bugs.debian.org/1074355
Forwarded: no
Last-Update: 2025-01-23

--- a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/extensions/helpers/SpaceAvailableExtensionImplTest.java
+++ b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/extensions/helpers/SpaceAvailableExtensionImplTest.java
@@ -63,34 +63,35 @@
         Path lclSftp = CommonTestSupportUtils.resolve(targetPath, SftpConstants.SFTP_SUBSYSTEM_NAME, getClass().getSimpleName(),
                 getCurrentTestName());
         Path parentPath = targetPath.getParent();
-        FileStore store = Files.getFileStore(lclSftp.getRoot());
-        final String queryPath = CommonTestSupportUtils.resolveRelativeRemotePath(parentPath, lclSftp);
-        final SpaceAvailableExtensionInfo expected = new SpaceAvailableExtensionInfo(store);
+        for (FileStore store: lclSftp.getRoot().getFileSystem().getFileStores()) {
+            final String queryPath = CommonTestSupportUtils.resolveRelativeRemotePath(parentPath, lclSftp);
+            final SpaceAvailableExtensionInfo expected = new SpaceAvailableExtensionInfo(store);
 
-        List<? extends SubsystemFactory> factories = sshd.getSubsystemFactories();
-        sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory() {
-            @Override
-            public Command createSubsystem(ChannelSession channel) throws IOException {
-                return new SftpSubsystem(channel, this) {
-                    @Override
-                    protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path) throws IOException {
-                        if (!queryPath.equals(path)) {
-                            throw new StreamCorruptedException(
-                                    "Mismatched query paths: expected=" + queryPath + ", actual=" + path);
+            List<? extends SubsystemFactory> factories = sshd.getSubsystemFactories();
+            sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory() {
+                @Override
+                public Command createSubsystem(ChannelSession channel) throws IOException {
+                    return new SftpSubsystem(channel, this) {
+                        @Override
+                        protected SpaceAvailableExtensionInfo doSpaceAvailable(int id, String path) throws IOException {
+                            if (!queryPath.equals(path)) {
+                                throw new StreamCorruptedException(
+                                        "Mismatched query paths: expected=" + queryPath + ", actual=" + path);
+                            }
+
+                            return expected;
                         }
+                    };
+                }
+            }));
 
-                        return expected;
-                    }
-                };
+            try (SftpClient sftp = createSingleSessionClient()) {
+                SpaceAvailableExtension ext = assertExtensionCreated(sftp, SpaceAvailableExtension.class);
+                SpaceAvailableExtensionInfo actual = ext.available(queryPath);
+                assertEquals("Mismatched information", expected, actual);
+            } finally {
+                sshd.setSubsystemFactories(factories);
             }
-        }));
-
-        try (SftpClient sftp = createSingleSessionClient()) {
-            SpaceAvailableExtension ext = assertExtensionCreated(sftp, SpaceAvailableExtension.class);
-            SpaceAvailableExtensionInfo actual = ext.available(queryPath);
-            assertEquals("Mismatched information", expected, actual);
-        } finally {
-            sshd.setSubsystemFactories(factories);
         }
     }
 }