The following code snippet in from TestBaseUtils:
protected static File asFile(String path) {
try {
URI uri = new URI(path);
if (uri.getScheme().equals("file")) {
return new File(uri.getPath());
} else {
throw new IllegalArgumentException("This path does not denote a
local file.");
}
} catch (URISyntaxException e) {
throw new IllegalArgumentException("This path does not describe a
valid local file URI.");
}
}
If uri does not have a scheme (e.g. "/home/something.txt"),
uri.getScheme().equals("file") throws a NullPointerException instead of an
IllegalArgumentException is thrown. I feel it would make more sense to
catch the NullPointerException at the end.
What do you guys think?
Peter