Skip to content

Commit

Permalink
Try to caputre exception
Browse files Browse the repository at this point in the history
  • Loading branch information
dain committed Aug 7, 2024
1 parent 131e712 commit efe3561
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/test/java/io/airlift/compress/v2/HadoopNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ private static void requireNativeZlib()
{
Configuration conf = new Configuration();
if (!ZlibFactory.isNativeZlibLoaded(conf)) {
Throwable cause = null;
try {
Method initIDs = ZlibCompressor.class.getDeclaredMethod("initIDs");
initIDs.setAccessible(true);
initIDs.invoke(null);
}
catch (ReflectiveOperationException e) {
cause = e;
Throwable cause = initZlib(ZlibCompressor.class);
if (cause == null) {
cause = initZlib(ZlibDecompressor.class);
}
throw new RuntimeException("native zlib is not loaded", cause);
}
Expand All @@ -91,6 +86,19 @@ private static void requireNativeZlib()
}
}

private static Throwable initZlib(Class<?> clazz)
{
try {
Method initIDs = clazz.getDeclaredMethod("initIDs");
initIDs.setAccessible(true);
initIDs.invoke(null);
return null;
}
catch (ReflectiveOperationException e) {
return e;
}
}

private static void setStatic(Field field, Object value)
throws IllegalAccessException
{
Expand Down

0 comments on commit efe3561

Please sign in to comment.