Skip to content

Commit

Permalink
improve error reporting on errors loading native lib
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Oct 22, 2024
1 parent 4033687 commit 9c54977
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions common/src/main/java/org/apache/comet/NativeBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@ public abstract class NativeBase {

private static final String libraryToLoad = System.mapLibraryName(NATIVE_LIB_NAME);
private static boolean loaded = false;
private static Throwable loadErr = null;
private static final String searchPattern = "libcomet-";

static {
if (!isLoaded()) {
try {
load();
} catch (Throwable th) {
LOG.warn("Failed to load comet library", th);
// logging may not be initialized yet, so also write to stderr
System.err.println("Failed to load comet library: " + th.getMessage());
loadErr = th;
}
}

public static synchronized boolean isLoaded() {
public static synchronized boolean isLoaded() throws Throwable {
if (loadErr != null) {
throw loadErr;
}
return loaded;
}

Expand Down

0 comments on commit 9c54977

Please sign in to comment.