<Sound Dev> RFR: 8142898: Prefer isFile()/isDirectory() over exists() in SoftSynthesizer
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Wed Nov 18 16:21:58 UTC 2015
This fix looks fine to me. Thanks.
On 12.11.15 23:29, Omair Majid wrote:
> * 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
> appropriate.
>
> There's one case where `new FileOutputStream(..)` can still be used on a
> directory:
>
> 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?
>
> Thanks,
> Omair
>
--
Best regards, Sergey.
More information about the sound-dev
mailing list