Skip to content

Commit

Permalink
Fix native libraries relocation
Browse files Browse the repository at this point in the history
Native libraries used by conscrypt and grpc/netty are not relocated to a
different name although their counterpart java classes are. This may
cause a conflict with applications using the same dependencies but
possibly different versions up to a JVM crash.

Modify maven-shade-plugin relocation configuration to rename the
libraries using snowflake shade base:
* relocate grpc/netty tcnative and epoll libraries (note that Netty java
  loader detects relocation automatically as long as the base is the
  same for the java classes and the native library (minus dot '.' being
  replaced with underscore '_'))
* relocate conscrypt native library and change the prefix used to find
  the library in NativeCryptoJni class
  • Loading branch information
laurentgo committed Nov 22, 2024
1 parent 1286a3e commit 348075e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
28 changes: 28 additions & 0 deletions FIPS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,22 @@
<pattern>io.grpc</pattern>
<shadedPattern>${shadeBase}.grpc</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.io_grpc_netty_shaded_netty_tcnative</pattern>
<shadedPattern>META-INF.native.${shadeNativeBase}_grpc_netty_shaded_netty_tcnative</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.libio_grpc_netty_shaded_netty_tcnative</pattern>
<shadedPattern>META-INF.native.lib${shadeNativeBase}_grpc_netty_shaded_netty_tcnative</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.io_grpc_netty_shaded_netty_transport_native_epoll</pattern>
<shadedPattern>META-INF.native.${shadeNativeBase}_grpc_netty_shaded_netty_transport_native_epoll</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.libio_grpc_netty_shaded_netty_transport_native_epoll</pattern>
<shadedPattern>META-INF.native.lib${shadeNativeBase}_grpc_netty_shaded_netty_transport_native_epoll</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>${shadeBase}.org.checkerframework</shadedPattern>
Expand All @@ -526,6 +542,18 @@
<pattern>org.conscrypt</pattern>
<shadedPattern>${shadeBase}.org.conscrypt</shadedPattern>
</relocation>
<relocation>
<pattern>conscrypt_openjdk_jni</pattern>
<shadedPattern>${shadeNativeBase}_conscrypt_openjdk_jni</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.conscrypt_openjdk_jni</pattern>
<shadedPattern>META-INF.native.${shadeNativeBase}_conscrypt_openjdk_jni</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.libconscrypt_openjdk_jni</pattern>
<shadedPattern>META-INF.native.lib${shadeNativeBase}_conscrypt_openjdk_jni</shadedPattern>
</relocation>
<relocation>
<pattern>opencensus</pattern>
<shadedPattern>${shadeBase}.opencensus</shadedPattern>
Expand Down
1 change: 1 addition & 0 deletions parent-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<relocationBase>net/snowflake/client/jdbc/internal</relocationBase>
<shadeBase>net.snowflake.client.jdbc.internal</shadeBase>
<shadeNativeBase>net_snowflake_client_jdbc_internal</shadeNativeBase>
<slf4j.version>2.0.13</slf4j.version>
<snowflake.common.version>5.1.4</snowflake.common.version>
<testCategory>net.snowflake.client.category.AllTestCategory</testCategory>
Expand Down
28 changes: 28 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,22 @@
<pattern>io.grpc</pattern>
<shadedPattern>${shadeBase}.grpc</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.io_grpc_netty_shaded_netty_tcnative</pattern>
<shadedPattern>META-INF.native.${shadeNativeBase}_grpc_netty_shaded_netty_tcnative</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.libio_grpc_netty_shaded_netty_tcnative</pattern>
<shadedPattern>META-INF.native.lib${shadeNativeBase}_grpc_netty_shaded_netty_tcnative</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.io_grpc_netty_shaded_netty_transport_native_epoll</pattern>
<shadedPattern>META-INF.native.${shadeNativeBase}_grpc_netty_shaded_netty_transport_native_epoll</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.libio_grpc_netty_shaded_netty_transport_native_epoll</pattern>
<shadedPattern>META-INF.native.lib${shadeNativeBase}_grpc_netty_shaded_netty_transport_native_epoll</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>${shadeBase}.org.checkerframework</shadedPattern>
Expand All @@ -959,6 +975,18 @@
<pattern>org.conscrypt</pattern>
<shadedPattern>${shadeBase}.org.conscrypt</shadedPattern>
</relocation>
<relocation>
<pattern>conscrypt_openjdk_jni</pattern>
<shadedPattern>${shadeNativeBase}_conscrypt_openjdk_jni</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.conscrypt_openjdk_jni</pattern>
<shadedPattern>META-INF.native.${shadeNativeBase}_conscrypt_openjdk_jni</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.libconscrypt_openjdk_jni</pattern>
<shadedPattern>META-INF.native.lib${shadeNativeBase}_conscrypt_openjdk_jni</shadedPattern>
</relocation>
<relocation>
<pattern>opencensus</pattern>
<shadedPattern>${shadeBase}.opencensus</shadedPattern>
Expand Down

0 comments on commit 348075e

Please sign in to comment.