* don't crash just because if there's something wrong with GVFS

This commit is contained in:
Reinhard Pointner 2012-11-24 06:27:24 +00:00
parent a5ed0351d1
commit 21fa1a19c4
1 changed files with 9 additions and 5 deletions

View File

@ -122,19 +122,23 @@ public class FileTransferable implements Transferable {
file = new File(uri); file = new File(uri);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// try handle other GVFS URI schemes // try handle other GVFS URI schemes
if (GVFS.isSupported()) { try {
file = GVFS.getPathForURI(uri); if (GVFS.isSupported()) {
file = GVFS.getPathForURI(uri);
}
} catch (LinkageError error) {
Logger.getLogger(FileTransferable.class.getName()).log(Level.WARNING, "Unable to resolve GVFS URI", e);
} }
} }
if (!file.exists()) { if (file == null || !file.exists()) {
throw new FileNotFoundException(file.toString()); throw new FileNotFoundException(line);
} }
files.add(file); files.add(file);
} catch (Throwable e) { } catch (Throwable e) {
// URISyntaxException, IllegalArgumentException, FileNotFoundException, LinkageError, etc // URISyntaxException, IllegalArgumentException, FileNotFoundException, LinkageError, etc
Logger.getLogger(FileTransferable.class.getName()).log(Level.WARNING, "Invalid file URI: " + line, e); Logger.getLogger(FileTransferable.class.getName()).log(Level.WARNING, "Invalid file URI: " + line);
} }
return files; return files;
} }