History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-26589
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Maxim Shafirov
Reporter: Brian Slesinsky
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

VirtualFile.getChildren() returns stale directory contents after VirtualFile.refresh()

Created: 14 May 08 01:20   Updated: 26 May 08 17:01
Component/s: Plugin Support. API
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. Java Source File RefreshChildrenTest.java (2 kb)

Environment: Linux

Build: 7,757


 Description  « Hide
I've attached a JUnit test demonstrating this bug. When run repeatedly, it passes and fails on alternate runs. When it fails, here is the error:

children:
/tmp/RefreshChildrenTest.testRefreshSeesLatestDirectoryContents/Foo.java
/tmp/RefreshChildrenTest.testRefreshSeesLatestDirectoryContents/Bar.java

junit.framework.AssertionFailedError: expected:<1> but was:<2>
at somepackage.RefreshChildrenTest.checkChildCount(RefreshChildrenTest.java:68)
at somepackage.RefreshChildrenTest.testRefreshSeesLatestDirectoryContents(RefreshChildrenTest.java:46)

This is a cleaned-up version of the unit test I showed Dmitry when he was in Mountain View.



 All   Comments   Work Log   Change History      Sort Order:
Dmitry Jemerov - 14 May 08 22:12
The test fails every other time in our environment too. Thanks a lot (again) for the report!

Brian Slesinsky - 21 May 08 07:23
Do you have any ideas about what causes this problem? Is there some workaround?

Maxim Shafirov - 26 May 08 17:01
Hi Brian,
This is actually is rather tough issue. The problem is caused by the fact refresh only refreshes instances of the VirtualFile, that are loaded in the particular IDEA session. In this test refresh(false, true) is called before getChildren() is called against that directory, thus refresh for the directory is 'optimized' away. So, the workaround would be calling virtualDir.getChildren() before virtualDir.refresh(false, true) in line 38