Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.0
-
None
Description
Simple test method. See all the bogus cases at the end:
public void testObjectsAfterMoveOfParentDoNotExistWithSFTP() throws IOException { final FileSystemOptions fsOptions = new FileSystemOptions(); final FileSystemManager fsManager = VFS.getManager(); final FileObject root = fsManager.resolveFile(SFTP_BASE_URL + "junit", fsOptions); if (!root.exists()) { root.createFolder(); } assertTrue(root.exists()); final FileObject target = root.resolveFile("target"); if (!target.exists()) { target.createFolder(); } assertTrue(target.exists()); final FileObject work = root.resolveFile("work"); if (!work.exists()) { work.createFolder(); } assertTrue(work.exists()); FileObject inWork = work.resolveFile("inWork"); if (!inWork.exists()) { inWork.createFolder(); } assertTrue(inWork.exists()); final FileObject ready = target.resolveFile("ready-" + System.currentTimeMillis()); assertFalse(ready.exists()); work.moveTo(ready); assertTrue(ready.exists()); assertFalse(work.exists()); try { assertFalse(inWork.exists()); fail("Thrown " + AssertionFailedError.class.getName() + " expected, because of buggy implementation"); } catch (final AssertionFailedError e) { // <sigh> } try { inWork.refresh(); assertFalse(inWork.exists()); fail("Thrown " + AssertionFailedError.class.getName() + " expected, because of buggy implementation"); } catch (final AssertionFailedError e) { // <sigh> } try { assertFalse(work.resolveFile("inWork").exists()); fail("Thrown " + AssertionFailedError.class.getName() + " expected, because of buggy implementation"); } catch (final AssertionFailedError e) { // <sigh> } try { work.refresh(); assertFalse(work.resolveFile("inWork").exists()); fail("Thrown " + AssertionFailedError.class.getName() + " expected, because of buggy implementation"); } catch (final AssertionFailedError e) { // <sigh> } // it even possible to write into a file of the non-existing folder ... FileObject file = inWork.resolveFile("test.txt"); OutputStream out = file.getContent().getOutputStream(); out.write("Foo".getBytes()); try { out.close(); } catch(IOException e) { // ignore this } assertTrue(file.exists()); // force update of references file = null; out = null; inWork = null; System.gc(); System.gc(); // ... aaaaahhhh ... something changed assertFalse(work.resolveFile("inWork").exists()); }
There's not a single possibility to tell VFS that the FileObject is bogus and even worse, you can write into non-existing files of a non-existing folder without getting an Exception ...
Attachments
Attachments
Issue Links
- causes
-
VFS-698 SFTP file attributes are fetched multiple times leading to very slow directory listing
- Closed