Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Broken behavior of java.io.File()

Thread view: 
Twisted - 23 Feb 2006 02:14 GMT
I'm seeing several examples of broken behavior with java.io.File():

* mkdirs() sometimes returns false, despite succeeding (the directories
exist afterward on the
 filesystem)
* exists() and isDirectory() sometimes return false when called on a
File object right after a
 mkdirs() after which the directory and its parents existed, as
observed using Winblows
 Exploder.

What is going on here? Is there even a way to test for the existence of
a directory with 100% accuracy?
Twisted - 23 Feb 2006 02:18 GMT
Bah. My bad again -- the breakpoint was set on if(!dir.isDir()) { and
not on the next line. So it was tripping when the dirs needed to be
created, whether or not it was successful. Bah bah bah! I need to sleep
before I do much more work on this thing...
Roedy Green - 23 Feb 2006 17:42 GMT
>* mkdirs() sometimes returns false, despite succeeding (the directories
>exist afterward on the
>  filesystem)

The alternative would to insist on atomic. If it dies part way
thorough it has to delete what it created. Then what if that fails?
having a few extra dirs is not going to hurt anything. I think that
choice was reasonable given the OS does not support atomic directory
node chain creation or deletion for that matter.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 23 Feb 2006 17:48 GMT
>What is going on here? Is there even a way to test for the existence of
>a directory with 100% accuracy?

that sounds like windows bug. I will speculate an WHY this happens.

Windows maintains a very expensive statistic, the time last accessed.
In theory the disks could spend their entire times updating the last
access date in the directories every time a byte is read anywhere in
the file tree, or at least is closed.  Perhaps it is defined only
measure  the last closed file -- in other words when the directory
itself was last modified.  

In any case procrastination is definitely called for.

I suspect though they over did it. They also procrastinated posting
even the existence of the directory.  Recall that Windows NT+ use a
transaction based system. Transactions to change the directory queue
up with CODASYL-like processing to make it recover in the even of a
crash during a multi sector write.

The directory existence transaction had not yet been processed.  Even
the in RAM cache apparently does not recognize the change until
officially posted.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 23 Feb 2006 17:56 GMT
>What is going on here? Is there even a way to test for the existence of
>a directory with 100% accuracy?

see http://mindprod.com/jgloss/file.html#MKDIRS
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.