You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Clears the cached {@code attrs} regardless of the {@code attached} state. The {@code attrs} field can be populated without going through {@code attach()}
503
+
* (e.g. via {@code setStat()} in {@code doListChildrenResolved()}), so {@code doDetach()} alone may not clear it if the file was never attached.
Copy file name to clipboardExpand all lines: commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpRefreshCachedStateTest.java
+23-34Lines changed: 23 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@
14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
+
17
18
packageorg.apache.commons.vfs2.provider.ftp;
18
19
19
20
importjava.io.File;
@@ -29,18 +30,25 @@
29
30
importorg.junit.jupiter.api.Test;
30
31
31
32
/**
32
-
* Tests that {@link org.apache.commons.vfs2.provider.AbstractFileObject#refresh()} correctly clears cached state
33
-
* even when the file was never attached.
33
+
* Tests that {@link org.apache.commons.vfs2.provider.AbstractFileObject#refresh()} correctly clears cached state even when the file was never attached.
34
34
* <p>
35
-
* Regression test for the bug in {@code AbstractFileObject.detach()} where the {@code if (attached)} guard
36
-
* prevented clearing cached fields ({@code type}, {@code parent}, {@code children}) on objects that were never
37
-
* attached. Provider-specific cached fields like {@code FtpFileObject.childMap} can be populated without going
38
-
* through {@code attach()} (e.g. via {@code getChildFile()} → {@code doGetChildren()}), so {@code refresh()}
39
-
* must clear cached state regardless of the {@code attached} flag.
35
+
* Regression test for the bug in {@code AbstractFileObject.detach()} where the {@code if (attached)} guard prevented clearing cached fields ({@code type},
36
+
* {@code parent}, {@code children}) on objects that were never attached. Provider-specific cached fields like {@code FtpFileObject.childMap} can be populated
37
+
* without going through {@code attach()} (e.g. via {@code getChildFile()} → {@code doGetChildren()}), so {@code refresh()} must clear cached state regardless
* Tests that {@code exists()} returns {@code false} for a file that was deleted from the FTP server,
65
-
* even when the parent's cached {@code childMap} was populated without {@code attach()}.
63
+
* Tests that {@code exists()} returns {@code false} for a file that was deleted from the FTP server, even when the parent's cached {@code childMap} was
64
+
* populated without {@code attach()}.
66
65
* <p>
67
-
* The scenario: a file exists, its parent's {@code childMap} is populated (via {@code getChildFile()}
68
-
* during the first {@code exists()} call), the file is then deleted on the server, and the parent's
69
-
* {@code refresh()} must clear the stale {@code childMap} so the next {@code exists()} returns
70
-
* {@code false}.
66
+
* The scenario: a file exists, its parent's {@code childMap} is populated (via {@code getChildFile()} during the first {@code exists()} call), the file is
67
+
* then deleted on the server, and the parent's {@code refresh()} must clear the stale {@code childMap} so the next {@code exists()} returns {@code false}.
71
68
* </p>
72
69
* <p>
73
-
* Before the fix, {@code refresh()} → {@code detach()} skipped cache clearing because the parent was
74
-
* never explicitly attached ({@code attached == false}), leaving stale data in {@code childMap}.
70
+
* Before the fix, {@code refresh()} → {@code detach()} skipped cache clearing because the parent was never explicitly attached ({@code attached == false}),
71
+
* leaving stale data in {@code childMap}.
75
72
* </p>
76
73
*/
77
74
@Test
@@ -80,32 +77,24 @@ public void testExistsReturnsFalseAfterFileDeletedAndParentRefreshed() throws Ex
Copy file name to clipboardExpand all lines: commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/sftp/SftpRefreshCachedStateTest.java
+11-23Lines changed: 11 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@
14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
+
17
18
packageorg.apache.commons.vfs2.provider.sftp;
18
19
19
20
importjava.io.File;
@@ -28,13 +29,11 @@
28
29
importorg.junit.jupiter.api.Test;
29
30
30
31
/**
31
-
* Tests that {@link SftpFileObject#refresh()} correctly clears cached {@code attrs}
32
-
* even when the file was never attached.
32
+
* Tests that {@link SftpFileObject#refresh()} correctly clears cached {@code attrs} even when the file was never attached.
33
33
* <p>
34
-
* Regression test for the bug where {@code attrs} can be populated without going through
35
-
* {@code attach()} (via {@code setStat()} in {@code doListChildrenResolved()}). Without
36
-
* the fix, {@code refresh()} skips clearing {@code attrs} because {@code attached == false},
37
-
* causing {@code exists()} to return stale results.
34
+
* Regression test for the bug where {@code attrs} can be populated without going through {@code attach()} (via {@code setStat()} in
35
+
* {@code doListChildrenResolved()}). Without the fix, {@code refresh()} skips clearing {@code attrs} because {@code attached == false}, causing
36
+
* {@code exists()} to return stale results.
38
37
* </p>
39
38
*/
40
39
publicclassSftpRefreshCachedStateTest {
@@ -50,37 +49,30 @@ public void tearDown() throws InterruptedException {
50
49
}
51
50
52
51
/**
53
-
* Tests that {@code exists()} returns {@code false} for a file that was deleted,
54
-
* when the child's {@code attrs} was populated via the parent's listing without
55
-
* {@code attach()}.
52
+
* Tests that {@code exists()} returns {@code false} for a file that was deleted, when the child's {@code attrs} was populated via the parent's listing
53
+
* without {@code attach()}.
56
54
* <p>
57
-
* The key is that we do NOT call {@code exists()} or {@code getType()} on the child
58
-
* before deleting — only the parent's {@code getChildren()} populates the child's
59
-
* {@code attrs} via {@code setStat()} (without triggering {@code attach()}).
60
-
* Then after deleting the file, {@code refresh()} must clear the stale {@code attrs}.
55
+
* The key is that we do NOT call {@code exists()} or {@code getType()} on the child before deleting — only the parent's {@code getChildren()} populates the
56
+
* child's {@code attrs} via {@code setStat()} (without triggering {@code attach()}). Then after deleting the file, {@code refresh()} must clear the stale
0 commit comments