commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] [Commented] (IO-389) FileUtils.sizeOfDirectory can throw IllegalArgumentException
Date Wed, 10 Jul 2013 09:29:49 GMT


Sebb commented on IO-389:

I agree that the exception is unexpected and unhelpful.
However, rather than call FileUtils.sizeOf and catch the Exception it might be better to inline
the main part of that code, i.e.

if (file.isDirectory()) {
   return sizeOfDirectory(file);
} else {
    return file.length();

Alternatively, create private versions that don't include the external checks.
For example, there's no point sizeOfDirectory checking if the file is a directory.
> FileUtils.sizeOfDirectory can throw IllegalArgumentException
> ------------------------------------------------------------
>                 Key: IO-389
>                 URL:
>             Project: Commons IO
>          Issue Type: Bug
>            Reporter: Austin Doupnik
>            Priority: Minor
>         Attachments: IO-389.patch
> FileUtils.sizeOfDirectory has a small concurrency issue. Between the call to File.listFiles
and the call to FileUtils.sizeOf, a file may be deleted. This can cause FileUtils.sizeOf to
throw an IllegalArgumentException, indicating that the file does not exist.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message