You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2004/07/24 12:25:38 UTC

[io] FileUtils null and exception handling

In adding a new method to FileUtils, I discovered how inconsistent the null
and exception handling is.

For example, FileUtils.toFile(URL) will not throw an exception if the URL is
non-file. It will throw a NPE (undocumented) if the url is null.

FileUtils.toURLs(File[]) will throw a NPE (undocumented) if the array or any
element is null. But it doesn't trap IOException when converting files to
URLs (which I believe shouldn't happen).


The trouble is that any changes are backwards incompatible. So, do we stick
with what we have, or fix the obviously bad cases?

My proposed regime would be:
- NPE for null input when it shouldn't be (I would prefer IAE, but NPE is
more widespread in [io] at the moment.
- IOException for errors that come from interaction with the filing
system/io
- IAE for errors that come from other processing not involving the filing
system
- When processing arrays/collections, return an empty array for null input
- When processing arrays/collections, return null item in the output if null
item found in the input
- Document everything

Stephen


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org