<Sound Dev> RFR: 8142898: Prefer isFile()/isDirectory() over exists() in SoftSynthesizer

Omair Majid omajid at redhat.com
Thu Nov 12 20:29:03 UTC 2015

* Omair Majid <omajid at redhat.com> [2015-10-26 18:08]:
> > My assumption that isFile() should be better choice.
> I agree, but I would like to work on this as a separate patch. Most of
> the code that calls `exists()` then proceeds to use `new
> FileInputStream()` on the result, which will probably fail if it is a
> directory. But it needs to be handled as an exception correctly.

Bug: https://bugs.openjdk.java.net/browse/JDK-8142898
Webrev: http://cr.openjdk.java.net/~omajid/webrevs/8142898-isFile-isDirectory-over-exists/00/

I switched all calls from exists() to isFile() or isDirectory() as

There's one case where `new FileOutputStream(..)` can still be used on a

        if (emg_soundbank_file.isFile()) {
            return null;
        return new FileOutputStream(emg_soundbank_file);
    } catch (final FileNotFoundException ignored) {

But the catch block should catch and handle the exception correctly. Or do you
think it's worth handling this special case?


PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681

More information about the sound-dev mailing list