ilang opened a new pull request, #758:
URL: https://github.com/apache/commons-vfs/pull/758

   ## Summary
   
   `AbstractFileObject.detach()` guards both `doDetach()` and cache clearing 
(`setFileType(null)`, `parent = null`, `removeChildrenCache()`) with `if 
(attached)`. This prevents clearing cached state on objects that were never 
attached.
   
   However, provider-specific cached fields like `FtpFileObject.childMap` can 
be populated without going through `attach()` (e.g. via `getChildFile()` → 
`doGetChildren()`). When `refresh()` calls `detach()` on such an object, the 
stale cached data is silently preserved, causing `exists()` to return incorrect 
results.
   
   ## Fix
   
   Move cache clearing (`setFileType`, `parent`, `removeChildrenCache`) outside 
the `if (attached)` guard so it always runs. The `doDetach()` call to the 
provider remains guarded, since providers should not be detached if they were 
never attached.
   
   ## Root cause
   
   The `if (attached)` guard was introduced in the original `detach()` 
implementation (2005) when `childMap` was only populated during `attach()` → 
`doGetType()`. Over the years, code paths were added that populate cached 
fields without `attach()` (like `getChildFile()` → `doGetChildren()`), making 
the guard incorrect.
   
   ## Test plan
   
   - [x] Full VFS2 test suite passes (3203 tests, 0 failures)
   - [x] Verified with debugger that `childMap` is correctly cleared after 
`refresh()` on unattached objects


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to