Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Broken behavior of java.io.File()

Reply
Thread Tools

Broken behavior of java.io.File()

 
 
Twisted
Guest
Posts: n/a
 
      02-23-2006
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?

 
Reply With Quote
 
 
 
 
Twisted
Guest
Posts: n/a
 
      02-23-2006
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...

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      02-23-2006
On 22 Feb 2006 18:14:29 -0800, "Twisted" <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>* 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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      02-23-2006
On 22 Feb 2006 18:14:29 -0800, "Twisted" <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>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.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      02-23-2006
On 22 Feb 2006 18:14:29 -0800, "Twisted" <(E-Mail Removed)> wrote,
quoted or indirectly quoted someone who said :

>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
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Broken alias behavior in Ruby 1.9.2? Tron Fu Ruby 4 08-30-2010 02:35 PM
Why are "broken iterators" broken? Steven D'Aprano Python 8 09-28-2008 09:19 PM
Re: Why are "broken iterators" broken? Fredrik Lundh Python 0 09-22-2008 04:32 PM
Re: Why are "broken iterators" broken? Cameron Simpson Python 0 09-22-2008 04:32 AM
undefined behavior or not undefined behavior? That is the question Mantorok Redgormor C Programming 70 02-17-2004 02:46 PM



Advertisments