Skip to content

Commit

Permalink
revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Aug 12, 2024
1 parent 2903314 commit ab8c823
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/software/amazon/awssdk/crt/CRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private static void extractAndLoadLibrary(String path) {
if (!tmpdirFile.canRead() || !tmpdirFile.canWrite()) {
throw new IOException("access denied: " + tmpdirPath);
}
} catch (Exception ex) {
} catch (IOException ex) {
CrtRuntimeException rex = new CrtRuntimeException("Invalid directory: " + path);
rex.initCause(ex);
throw rex;
Expand All @@ -345,8 +345,17 @@ private static void extractAndLoadLibrary(String path) {

// Prefix the lib we'll extract to disk
String tempSharedLibPrefix = "AWSCRT_";
File tempSharedLib = File.createTempFile(tempSharedLibPrefix, libraryName, tmpdirFile);

File tempSharedLib = null;
try{
tempSharedLib = File.createTempFile(tempSharedLibPrefix, libraryName, tmpdirFile);
}
catch (IOException ex){
System.err.println("Unable to create temp file to extract AWS CRT library" + ex);
ex.printStackTrace();
CrtRuntimeException rex = new CrtRuntimeException("Unable to create temp file to extract AWS CRT library");
rex.initCause(ex);
throw rex;
}
// The temp lib file should be deleted when we're done with it.
// Ask Java to try and delete it on exit. We call this immediately
// so that if anything goes wrong writing the file to disk, or
Expand All @@ -367,6 +376,7 @@ private static void extractAndLoadLibrary(String path) {
extractLibrary(tempSharedLib);
// load the shared lib from the temp path
System.load(tempSharedLib.getAbsolutePath());

}

private static void loadLibraryFromJar() {
Expand Down

0 comments on commit ab8c823

Please sign in to comment.