Improve exception handling for os.write.

* Replace catch wildcard Exception with Throwable when handling errors on write of temporary library file.
* Fixed typo on "prefix" in comment.
* Removed unused java.net.URI import.
This commit is contained in:
Isabell Cowan
2017-09-03 21:20:32 -05:00
parent ac61a4a32d
commit 305a9c9ce8

View File

@@ -24,7 +24,6 @@
package cz.adamh.utils;
import java.io.*;
import java.net.URI;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.ProviderNotFoundException;
@@ -67,7 +66,7 @@ public class NativeUtils {
String[] parts = path.split("/");
String filename = (parts.length > 1) ? parts[parts.length - 1] : null;
// Split filename to prexif and suffix (extension)
// Split filename to prefix and suffix (extension)
String prefix = "";
String suffix = null;
if (filename != null) {
@@ -119,7 +118,7 @@ public class NativeUtils {
while ((readBytes = is.read(buffer)) != -1) {
os.write(buffer, 0, readBytes);
}
} catch (Exception e) {
} catch (Throwable e) {
temp.delete();
throw e;
} finally {