Skip to content

Commit

Permalink
fix npe
Browse files Browse the repository at this point in the history
Signed-off-by: chenxu <[email protected]>
  • Loading branch information
dmetasoul01 committed Nov 22, 2024
1 parent d21bfcc commit ac25f33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -38,7 +39,11 @@ public synchronized static void tryLoad() {
String finalPath = null;

try {
URLConnection connection = JnrLoader.class.getResource(libName).openConnection();
URL url = JnrLoader.class.getClassLoader().getResource(libName);
if (url == null) {
throw new FileNotFoundException(libName);
}
URLConnection connection = url.openConnection();
if (connection != null) {
connection.setUseCaches(false);
try (final InputStream is = connection.getInputStream()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -39,7 +40,11 @@ public synchronized static void tryLoad() {
String finalPath = null;

try {
URLConnection connection = com.dmetasoul.lakesoul.meta.jnr.JnrLoader.class.getResource(libName).openConnection();
URL url = JnrLoader.class.getClassLoader().getResource(libName);
if (url == null) {
throw new FileNotFoundException(libName);
}
URLConnection connection = url.openConnection();
if (connection != null) {
connection.setUseCaches(false);
try (final InputStream is = connection.getInputStream()) {
Expand Down

0 comments on commit ac25f33

Please sign in to comment.