This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e2c6ef082 Add temp dir property for native library (#4533)
1e2c6ef082 is described below

commit 1e2c6ef082b53742fa4d7a405f2ab952e6e3df88
Author: Yuri Mizushima <[email protected]>
AuthorDate: Wed Feb 5 01:28:29 2025 +0900

    Add temp dir property for native library (#4533)
    
    * feat: add temp dir property for native library
    
    * refactor: create new submodule native-library-common to merge NativeUtils
    
    * fix: remove guava from native-library-common
---
 circe-checksum/pom.xml                             |  5 ++
 .../java/com/scurrilous/circe/crc/Sse42Crc32C.java |  4 +-
 cpu-affinity/pom.xml                               |  5 ++
 .../common/util/affinity/impl/CpuAffinityImpl.java |  1 +
 .../common/util/affinity/impl/NativeUtils.java     | 90 ----------------------
 native-io/pom.xml                                  |  5 ++
 .../common/util/nativeio/NativeIOJni.java          |  1 +
 .../common/util/nativeio/NativeUtils.java          | 85 --------------------
 .../common/util/nativeio/package-info.java         |  2 +-
 native-library-common/pom.xml                      | 46 +++++++++++
 .../common/util/nativelib}/NativeUtils.java        | 67 ++++++++++------
 .../common/util/nativelib}/package-info.java       |  4 +-
 .../common/util/nativelib/NativeUtilsTest.java     |  4 +-
 pom.xml                                            |  1 +
 shaded/bookkeeper-server-shaded/pom.xml            |  1 +
 shaded/distributedlog-core-shaded/pom.xml          |  1 +
 .../shaded/distributedlog-core-shaded-test/pom.xml |  4 +
 .../shaded/DistributedLogCoreShadedJarTest.java    | 11 +++
 18 files changed, 131 insertions(+), 206 deletions(-)

diff --git a/circe-checksum/pom.xml b/circe-checksum/pom.xml
index 9f9ca5f0c6..376619c635 100644
--- a/circe-checksum/pom.xml
+++ b/circe-checksum/pom.xml
@@ -39,6 +39,11 @@
   </properties>
 
   <dependencies>
+    <dependency>
+      <groupId>org.apache.bookkeeper</groupId>
+      <artifactId>native-library-common</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
 
     <dependency>
       <groupId>com.google.guava</groupId>
diff --git 
a/circe-checksum/src/main/java/com/scurrilous/circe/crc/Sse42Crc32C.java 
b/circe-checksum/src/main/java/com/scurrilous/circe/crc/Sse42Crc32C.java
index 22379a0e32..01a40e4b5c 100644
--- a/circe-checksum/src/main/java/com/scurrilous/circe/crc/Sse42Crc32C.java
+++ b/circe-checksum/src/main/java/com/scurrilous/circe/crc/Sse42Crc32C.java
@@ -15,8 +15,8 @@
  
******************************************************************************/
 package com.scurrilous.circe.crc;
 
-import static com.scurrilous.circe.utils.NativeUtils.loadLibraryFromJar;
-import static com.scurrilous.circe.utils.NativeUtils.libType;
+import static org.apache.bookkeeper.common.util.nativelib.NativeUtils.libType;
+import static 
org.apache.bookkeeper.common.util.nativelib.NativeUtils.loadLibraryFromJar;
 
 import java.nio.ByteBuffer;
 import com.scurrilous.circe.IncrementalIntHash;
diff --git a/cpu-affinity/pom.xml b/cpu-affinity/pom.xml
index 5ba9bc95de..5839c916ce 100644
--- a/cpu-affinity/pom.xml
+++ b/cpu-affinity/pom.xml
@@ -33,6 +33,11 @@
   </properties>
 
   <dependencies>
+    <dependency>
+      <groupId>org.apache.bookkeeper</groupId>
+      <artifactId>native-library-common</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
diff --git 
a/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/CpuAffinityImpl.java
 
b/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/CpuAffinityImpl.java
index 380509c2fb..94c494f903 100644
--- 
a/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/CpuAffinityImpl.java
+++ 
b/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/CpuAffinityImpl.java
@@ -34,6 +34,7 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 import lombok.experimental.UtilityClass;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.common.util.nativelib.NativeUtils;
 
 /**
  * Implementation of CPU Affinity functionality.
diff --git 
a/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/NativeUtils.java
 
b/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/NativeUtils.java
deleted file mode 100644
index fde69f9011..0000000000
--- 
a/cpu-affinity/src/main/java/org/apache/bookkeeper/common/util/affinity/impl/NativeUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.bookkeeper.common.util.affinity.impl;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import lombok.NonNull;
-import lombok.experimental.UtilityClass;
-
-/**
- * Utility class to load jni library from inside a JAR.
- */
-@UtilityClass
-public class NativeUtils {
-    /**
-     * loads given library from the this jar. ie: this jar contains: 
/lib/pulsar-checksum.jnilib
-     *
-     * @param path
-     *            : absolute path of the library in the jar <br/>
-     *            if this jar contains: /lib/pulsar-checksum.jnilib then 
provide the same absolute path as input
-     * @throws Exception
-     */
-    @SuppressFBWarnings(
-            value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
-            justification = "work around for java 9: 
https://github.com/spotbugs/spotbugs/issues/493";)
-    public static void loadLibraryFromJar(String path) throws Exception {
-        checkArgument(path.startsWith("/"), "absolute path must start with /");
-
-        String[] parts = path.split("/");
-        checkArgument(parts.length > 0, "absolute path must contain file 
name");
-
-        String filename = parts[parts.length - 1];
-        checkArgument(path.startsWith("/"), "absolute path must start with /");
-
-        Path dir = Files.createTempDirectory("native");
-        dir.toFile().deleteOnExit();
-        File temp = new File(dir.toString(), filename);
-        temp.deleteOnExit();
-
-        byte[] buffer = new byte[1024];
-        int read;
-
-        try (InputStream input = NativeUtils.class.getResourceAsStream(path);
-                OutputStream out = new FileOutputStream(temp)) {
-            if (input == null) {
-                throw new FileNotFoundException("Couldn't find file into jar " 
+ path);
-            }
-
-            while ((read = input.read(buffer)) != -1) {
-                out.write(buffer, 0, read);
-            }
-        }
-
-        if (!temp.exists()) {
-            throw new FileNotFoundException("Failed to copy file from jar at " 
+ temp.getAbsolutePath());
-        }
-
-        System.load(temp.getAbsolutePath());
-    }
-
-    private static void checkArgument(boolean expression, @NonNull Object 
errorMessage) {
-        if (!expression) {
-            throw new IllegalArgumentException(String.valueOf(errorMessage));
-        }
-    }
-}
diff --git a/native-io/pom.xml b/native-io/pom.xml
index 6c7c7fe9f0..923ea43dbe 100644
--- a/native-io/pom.xml
+++ b/native-io/pom.xml
@@ -34,6 +34,11 @@
   </properties>
 
   <dependencies>
+    <dependency>
+      <groupId>org.apache.bookkeeper</groupId>
+      <artifactId>native-library-common</artifactId>
+      <version>${project.parent.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
diff --git 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeIOJni.java
 
b/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeIOJni.java
index 77d2e80b01..beaeff24ac 100644
--- 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeIOJni.java
+++ 
b/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeIOJni.java
@@ -20,6 +20,7 @@
  */
 package org.apache.bookkeeper.common.util.nativeio;
 
+import org.apache.bookkeeper.common.util.nativelib.NativeUtils;
 import org.apache.commons.lang3.SystemUtils;
 
 class NativeIOJni {
diff --git 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeUtils.java
 
b/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeUtils.java
deleted file mode 100644
index b3bdf9ab2f..0000000000
--- 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/NativeUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.bookkeeper.common.util.nativeio;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import lombok.NonNull;
-import lombok.experimental.UtilityClass;
-
-/**
- * Utility class to load jni library from inside a JAR.
- */
-@UtilityClass
-class NativeUtils {
-    /**
-     * loads given library from the this jar. ie: this jar contains: 
/lib/pulsar-checksum.jnilib
-     *
-     * @param path
-     *            : absolute path of the library in the jar <br/>
-     *            if this jar contains: /lib/pulsar-checksum.jnilib then 
provide the same absolute path as input
-     * @throws Exception
-     */
-    @SuppressFBWarnings(
-            value = "OBL_UNSATISFIED_OBLIGATION",
-            justification = "work around for java 9: 
https://github.com/spotbugs/spotbugs/issues/493";)
-    static void loadLibraryFromJar(String path) throws Exception {
-        checkArgument(path.startsWith("/"), "absolute path must start with /");
-
-        String[] parts = path.split("/");
-        checkArgument(parts.length > 0, "absolute path must contain file 
name");
-
-        String filename = parts[parts.length - 1];
-
-        File dir = Files.createTempDirectory("native").toFile();
-        dir.deleteOnExit();
-        File temp = new File(dir, filename);
-        temp.deleteOnExit();
-
-        byte[] buffer = new byte[1024];
-        int read;
-
-        try (InputStream input = NativeUtils.class.getResourceAsStream(path);
-             OutputStream out = new FileOutputStream(temp)) {
-            if (input == null) {
-                throw new FileNotFoundException("Couldn't find file into jar " 
+ path);
-            }
-
-            while ((read = input.read(buffer)) != -1) {
-                out.write(buffer, 0, read);
-            }
-        }
-
-        if (!temp.exists()) {
-            throw new FileNotFoundException("Failed to copy file from jar at " 
+ temp.getAbsolutePath());
-        }
-
-        System.load(temp.getAbsolutePath());
-    }
-
-    public static void checkArgument(boolean expression, @NonNull Object 
errorMessage) {
-        if (!expression) {
-            throw new IllegalArgumentException(String.valueOf(errorMessage));
-        }
-    }}
diff --git 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
 
b/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
index d215e47087..2ba42fcdac 100644
--- 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
+++ 
b/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
@@ -17,6 +17,6 @@
  */
 
 /**
- * Utiltiies to access I/O using JNI.
+ * Utilities to access I/O using JNI.
  */
 package org.apache.bookkeeper.common.util.nativeio;
diff --git a/native-library-common/pom.xml b/native-library-common/pom.xml
new file mode 100644
index 0000000000..c334259350
--- /dev/null
+++ b/native-library-common/pom.xml
@@ -0,0 +1,46 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.bookkeeper</groupId>
+    <artifactId>bookkeeper</artifactId>
+    <version>4.18.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <artifactId>native-library-common</artifactId>
+  <name>Apache BookKeeper :: Common for Native Libraries</name>
+  <description>Common for Native Libraries</description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git 
a/circe-checksum/src/main/java/com/scurrilous/circe/utils/NativeUtils.java 
b/native-library-common/src/main/java/org/apache/bookkeeper/common/util/nativelib/NativeUtils.java
similarity index 60%
rename from 
circe-checksum/src/main/java/com/scurrilous/circe/utils/NativeUtils.java
rename to 
native-library-common/src/main/java/org/apache/bookkeeper/common/util/nativelib/NativeUtils.java
index bd950616c5..fbd70c3747 100644
--- a/circe-checksum/src/main/java/com/scurrilous/circe/utils/NativeUtils.java
+++ 
b/native-library-common/src/main/java/org/apache/bookkeeper/common/util/nativelib/NativeUtils.java
@@ -1,4 +1,5 @@
 /*
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -15,10 +16,9 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package com.scurrilous.circe.utils;
-
-import static com.google.common.base.Preconditions.checkArgument;
+package org.apache.bookkeeper.common.util.nativelib;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -28,13 +28,19 @@ import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Locale;
+import lombok.NonNull;
+import lombok.experimental.UtilityClass;
 
 /**
- * Utils for loading native checksum library.
+ * Utility class to load jni library from inside a JAR.
  */
+@UtilityClass
 public class NativeUtils {
 
     public static final String OS_NAME = 
System.getProperty("os.name").toLowerCase(Locale.US);
+    public static final String TEMP_WORKDIR_PROPERTY_NAME = 
"org.apache.bookkeeper.native.workdir";
+
+    private static final String TEMP_DIR_NAME = "native";
 
     /**
      * loads given library from the this jar. ie: this jar contains: 
/lib/pulsar-checksum.jnilib
@@ -44,37 +50,45 @@ public class NativeUtils {
      *            if this jar contains: /lib/pulsar-checksum.jnilib then 
provide the same absolute path as input
      * @throws Exception
      */
-    public static void loadLibraryFromJar(String path) throws Exception {
 
-        checkArgument(path.startsWith("/"), "absolute path must start with  
/");
+    public static void loadLibraryFromJar(String path) throws Exception {
+        checkArgument(path.startsWith("/"), "absolute path must start with /");
 
         String[] parts = path.split("/");
-        String filename = (parts.length > 0) ? parts[parts.length - 1] : null;
+        checkArgument(parts.length > 0, "absolute path must contain file 
name");
 
-        Path dir = Files.createTempDirectory("native");
+        String filename = parts[parts.length - 1];
+
+        // create the temp dir
+        final Path dir;
+        final String tempWorkDirName = 
System.getProperty(TEMP_WORKDIR_PROPERTY_NAME);
+        if (tempWorkDirName == null || tempWorkDirName.isEmpty()) {
+            dir = Files.createTempDirectory(TEMP_DIR_NAME);
+        } else {
+            final File tempWorkDir = new File(tempWorkDirName);
+            if (!tempWorkDir.exists() || !tempWorkDir.isDirectory()) {
+                throw new FileNotFoundException("The tempWorkDir doesn't 
exist: " + tempWorkDirName);
+            }
+            dir = Files.createTempDirectory(tempWorkDir.toPath(), 
TEMP_DIR_NAME);
+        }
         dir.toFile().deleteOnExit();
+
+        // create the temp file
         File temp = new File(dir.toString(), filename);
         temp.deleteOnExit();
 
         byte[] buffer = new byte[1024];
         int read;
 
-        InputStream input = NativeUtils.class.getResourceAsStream(path);
-        if (input == null) {
-            throw new FileNotFoundException("Couldn't find file into jar " + 
path);
-        }
+        try (InputStream input = NativeUtils.class.getResourceAsStream(path);
+             OutputStream out = new FileOutputStream(temp)) {
+            if (input == null) {
+                throw new FileNotFoundException("Couldn't find file into jar " 
+ path);
+            }
 
-        try {
-            OutputStream out = new FileOutputStream(temp);
-            try {
-                while ((read = input.read(buffer)) != -1) {
-                    out.write(buffer, 0, read);
-                }
-            } finally {
-                out.close();
+            while ((read = input.read(buffer)) != -1) {
+                out.write(buffer, 0, read);
             }
-        } finally {
-            input.close();
         }
 
         if (!temp.exists()) {
@@ -88,10 +102,9 @@ public class NativeUtils {
      * Returns jni library extension based on OS specification. Maven-nar 
generates jni library based on different OS :
      * http://mark.donszelmann.org/maven-nar-plugin/aol.html (jni.extension)
      *
-     * @return
+     * @return library type
      */
     public static String libType() {
-
         if (OS_NAME.indexOf("mac") >= 0) {
             return "jnilib";
         } else if (OS_NAME.indexOf("nix") >= 0 || OS_NAME.indexOf("nux") >= 0 
|| OS_NAME.indexOf("aix") > 0) {
@@ -101,4 +114,10 @@ public class NativeUtils {
         }
         throw new TypeNotPresentException(OS_NAME + " not supported", null);
     }
+
+    public static void checkArgument(boolean expression, @NonNull Object 
errorMessage) {
+        if (!expression) {
+            throw new IllegalArgumentException(String.valueOf(errorMessage));
+        }
+    }
 }
diff --git 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
 
b/native-library-common/src/main/java/org/apache/bookkeeper/common/util/nativelib/package-info.java
similarity index 90%
copy from 
native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
copy to 
native-library-common/src/main/java/org/apache/bookkeeper/common/util/nativelib/package-info.java
index d215e47087..9c08198d08 100644
--- 
a/native-io/src/main/java/org/apache/bookkeeper/common/util/nativeio/package-info.java
+++ 
b/native-library-common/src/main/java/org/apache/bookkeeper/common/util/nativelib/package-info.java
@@ -17,6 +17,6 @@
  */
 
 /**
- * Utiltiies to access I/O using JNI.
+ * Utilities for Native Libraries.
  */
-package org.apache.bookkeeper.common.util.nativeio;
+package org.apache.bookkeeper.common.util.nativelib;
diff --git 
a/circe-checksum/src/test/java/com/scurrilous/circe/utils/NativeUtilsTests.java 
b/native-library-common/src/test/java/org/apache/bookkeeper/common/util/nativelib/NativeUtilsTest.java
similarity index 94%
rename from 
circe-checksum/src/test/java/com/scurrilous/circe/utils/NativeUtilsTests.java
rename to 
native-library-common/src/test/java/org/apache/bookkeeper/common/util/nativelib/NativeUtilsTest.java
index 17bb45ace2..d868ede1a3 100644
--- 
a/circe-checksum/src/test/java/com/scurrilous/circe/utils/NativeUtilsTests.java
+++ 
b/native-library-common/src/test/java/org/apache/bookkeeper/common/util/nativelib/NativeUtilsTest.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package com.scurrilous.circe.utils;
+package org.apache.bookkeeper.common.util.nativelib;
 
 import java.io.FileNotFoundException;
 import org.junit.Assert;
@@ -25,7 +25,7 @@ import org.junit.Test;
 /**
  * Unit test of {@link NativeUtils}.
  */
-public class NativeUtilsTests {
+public class NativeUtilsTest {
 
     @Test
     public void testLoadLibrary() throws Exception {
diff --git a/pom.xml b/pom.xml
index ee68a53127..f8224775e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,6 +52,7 @@
   </ciManagement>
   <modules>
     <module>buildtools</module>
+    <module>native-library-common</module>
     <module>circe-checksum</module>
     <module>bookkeeper-common</module>
     <module>bookkeeper-common-allocator</module>
diff --git a/shaded/bookkeeper-server-shaded/pom.xml 
b/shaded/bookkeeper-server-shaded/pom.xml
index 1fea94ef15..89e22a81ba 100644
--- a/shaded/bookkeeper-server-shaded/pom.xml
+++ b/shaded/bookkeeper-server-shaded/pom.xml
@@ -75,6 +75,7 @@
                   <include>com.google.protobuf:protobuf-java</include>
                   <include>org.apache.bookkeeper:bookkeeper-common</include>
                   
<include>org.apache.bookkeeper:bookkeeper-common-allocator</include>
+                  
<include>org.apache.bookkeeper:native-library-common</include>
                   <include>org.apache.bookkeeper:cpu-affinity</include>
                   
<include>org.apache.bookkeeper:bookkeeper-tools-framework</include>
                   <include>org.apache.bookkeeper:bookkeeper-proto</include>
diff --git a/shaded/distributedlog-core-shaded/pom.xml 
b/shaded/distributedlog-core-shaded/pom.xml
index 36e18f6b64..37fa39f7d7 100644
--- a/shaded/distributedlog-core-shaded/pom.xml
+++ b/shaded/distributedlog-core-shaded/pom.xml
@@ -77,6 +77,7 @@
                   <include>net.jpountz.lz4:lz4</include>
                   <include>org.apache.bookkeeper:bookkeeper-common</include>
                   
<include>org.apache.bookkeeper:bookkeeper-common-allocator</include>
+                  
<include>org.apache.bookkeeper:native-library-common</include>
                   <include>org.apache.bookkeeper:cpu-affinity</include>
                   
<include>org.apache.bookkeeper:bookkeeper-tools-framework</include>
                   <include>org.apache.bookkeeper:bookkeeper-proto</include>
diff --git a/tests/shaded/distributedlog-core-shaded-test/pom.xml 
b/tests/shaded/distributedlog-core-shaded-test/pom.xml
index b2a2ed716a..11d3c8668b 100644
--- a/tests/shaded/distributedlog-core-shaded-test/pom.xml
+++ b/tests/shaded/distributedlog-core-shaded-test/pom.xml
@@ -48,6 +48,10 @@
           <groupId>org.apache.bookkeeper</groupId>
           <artifactId>circe-checksum</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId>org.apache.bookkeeper</groupId>
+          <artifactId>native-library-common</artifactId>
+        </exclusion>
         <exclusion>
           <groupId>org.apache.distributedlog</groupId>
           <artifactId>distributedlog-core</artifactId>
diff --git 
a/tests/shaded/distributedlog-core-shaded-test/src/test/java/org/apache/bookkeeper/tests/shaded/DistributedLogCoreShadedJarTest.java
 
b/tests/shaded/distributedlog-core-shaded-test/src/test/java/org/apache/bookkeeper/tests/shaded/DistributedLogCoreShadedJarTest.java
index 9dc6ee0193..21463070a5 100644
--- 
a/tests/shaded/distributedlog-core-shaded-test/src/test/java/org/apache/bookkeeper/tests/shaded/DistributedLogCoreShadedJarTest.java
+++ 
b/tests/shaded/distributedlog-core-shaded-test/src/test/java/org/apache/bookkeeper/tests/shaded/DistributedLogCoreShadedJarTest.java
@@ -111,6 +111,17 @@ public class DistributedLogCoreShadedJarTest {
         Class.forName("com.scurrilous.circe.checksum.Crc32cIntChecksum");
     }
 
+    @Test
+    public void testBookKeeperNativeLibraryCommonShade() throws Exception {
+        
Class.forName("dlshade.org.apache.bookkeeper.common.util.nativelib.NativeUtils");
+        assertTrue(true);
+    }
+
+    @Test(expected = ClassNotFoundException.class)
+    public void testBookKeeperNativeLibraryCommon() throws Exception {
+        
Class.forName("org.apache.bookkeeper.common.util.nativelib.NativeUtils");
+    }
+
     @Test
     public void testCirceChecksumShade() throws Exception {
         
Class.forName("dlshade.com.scurrilous.circe.checksum.Crc32cIntChecksum");

Reply via email to