Which begs the question... Is a flaky shared drive a common enough (and recoverable enough) situation that it justifies forcing all API users to make an explicit check for the condition with each and every function call that manipulates files?
On 22 September 2010 06:31, Ricky Clarkson <[email protected]> wrote: > Kevin, > > That reminds me of some code I inherited: > > if (file.exists()) { > try { > new FileInputStream(file).... > } > catch (FileNotFoundException e) { > //impossible since we checked the file before > } > } > > Guess what? It wasn't impossible, it happened occasionally because of a > flaky shared drive. File systems are not under the program's control, so it > is unsafe to check-then-assume. Even worse, the above would not work for > files that only come into existence when opened, like nodes in /dev, /proc > or /mnt on some systems. > > > On Wed, Sep 22, 2010 at 12:03 AM, Kevin Wright > <[email protected]>wrote: > >> In what context? >> >> When opening a named file, it should be normal control flow to discover >> the name isn't valid. >> When performing subsequent operations on an already-opened handle, it's >> truly exceptional if the thing has since gone missing, >> >> combining the operations is just poor design >> >> >> 2010/9/21 Cédric Beust ♔ <[email protected]> >> >>> >>> >>> On Tue, Sep 21, 2010 at 3:47 PM, Kevin Wright < >>> [email protected]> wrote: >>> >>>> What would you propose as a good example? >>>> >>> >>> An example of a good checked exception? >>> >>> How about FileNotFoundException? >>> >>> -- >>> Cédric >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "The Java Posse" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]<javaposse%[email protected]> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/javaposse?hl=en. >>> >> >> >> >> -- >> Kevin Wright >> >> mail / gtalk / msn : [email protected] >> pulse / skype: kev.lee.wright >> twitter: @thecoda >> >> -- >> You received this message because you are subscribed to the Google >> Groups "The Java Posse" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<javaposse%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/javaposse?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > -- Kevin Wright mail / gtalk / msn : [email protected] pulse / skype: kev.lee.wright twitter: @thecoda -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
