Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-40907: [Java][FlightSQL] Shade slf4j-api in JDBC driver #40908

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
import java.util.logging.Logger;

import org.apache.arrow.driver.jdbc.utils.ArrowFlightConnectionConfigImpl.ArrowFlightConnectionProperty;
import org.apache.arrow.driver.jdbc.utils.UrlParser;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class ArrowFlightJdbcDriver extends UnregisteredDriver {
// Netty requires some extra properties to unlock some native memory management api
// Setting this property if not already set externally
// This has to be done before any netty class is being loaded
final String key = "cfjd.io.netty.tryReflectionSetAccessible";
final String key = "io.netty.tryReflectionSetAccessible";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to support both the old and the new keys to minimize potential compatibility breaks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lidavidm do you mean testing/shading both cfjd and regular shading ? I think it could be confusing for users. Just wondering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main use of this property is to be set directly by the driver (not the users) in order for the driver to actually work. Checking if it is set sounds more like a debugging capability.

final String tryReflectionSetAccessible = System.getProperty(key);
if (tryReflectionSetAccessible == null) {
System.setProperty(key, Boolean.TRUE.toString());
Expand All @@ -67,6 +68,13 @@ public class ArrowFlightJdbcDriver extends UnregisteredDriver {
new ArrowFlightJdbcDriver().register();
}

@Override
public Logger getParentLogger() {
// Return the logger associated with the driver package ('org.apache.arrow.driver.jdbc')
// When packaged in flight-sql-jdbc-driver, it will also apply to all shaded dependencies
return Logger.getLogger(getClass().getPackage().getName());
}

@Override
public ArrowFlightConnection connect(final String url, final Properties info)
throws SQLException {
Expand Down
20 changes: 12 additions & 8 deletions java/flight/flight-sql-jdbc-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
<artifactId>slf4j-api</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.netty</groupId>
Expand Down Expand Up @@ -190,17 +195,16 @@
<relocations>
<relocation>
<pattern>com.</pattern>
<shadedPattern>cfjd.com.</shadedPattern>
<shadedPattern>org.apache.arrow.driver.jdbc.shaded.com.</shadedPattern>
<excludes>
<exclude>com.sun.**</exclude>
</excludes>
</relocation>
<relocation>
<pattern>org.</pattern>
<shadedPattern>cfjd.org.</shadedPattern>
<shadedPattern>org.apache.arrow.driver.jdbc.shaded.org.</shadedPattern>
<excludes>
<exclude>org.apache.arrow.driver.jdbc.**</exclude>
<exclude>org.slf4j.**</exclude>
<!-- Avoid shading Flight JDBC Properties -->
<exclude>org.apache.arrow.flight.name</exclude>
<exclude>org.apache.arrow.flight.version</exclude>
Expand All @@ -210,24 +214,24 @@
</relocation>
<relocation>
<pattern>io.</pattern>
<shadedPattern>cfjd.io.</shadedPattern>
<shadedPattern>org.apache.arrow.driver.jdbc.shaded.io.</shadedPattern>
</relocation>
<relocation>
<pattern>net.</pattern>
<shadedPattern>cfjd.net.</shadedPattern>
<shadedPattern>org.apache.arrow.driver.jdbc.shaded.net.</shadedPattern>
</relocation>
<relocation>
<pattern>mozilla.</pattern>
<shadedPattern>cfjd.mozilla.</shadedPattern>
<shadedPattern>org.apache.arrow.driver.jdbc.shaded.mozilla.</shadedPattern>
</relocation>
<!-- Entries to relocate netty native libraries -->
<relocation>
<pattern>META-INF.native.libnetty_</pattern>
<shadedPattern>META-INF.native.libcfjd_netty_</shadedPattern>
<shadedPattern>META-INF.native.liboaadj_netty_</shadedPattern>
</relocation>
<relocation>
<pattern>META-INF.native.netty_</pattern>
<shadedPattern>META-INF.native.cfjd_netty_</shadedPattern>
<shadedPattern>META-INF.native.oaadj_netty_</shadedPattern>
</relocation>
</relocations>
<transformers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
/**
* Check the content of the JDBC driver jar
*
* After shading everything should be either under org.apache.arrow.driver.jdbc.,
* org.slf4j., or cfjd. packages
* After shading everything should be either under org.apache.arrow.driver.jdbc. package
*/
public class ITDriverJarValidation {
/**
Expand All @@ -57,8 +56,6 @@ public class ITDriverJarValidation {
*/
public static final Set<String> ALLOWED_PREFIXES = ImmutableSet.of(
"org/apache/arrow/driver/jdbc/",
"cfjd/",
"org/slf4j/",
"META-INF/");

/**
Expand Down
5 changes: 5 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@
<artifactId>slf4j-api</artifactId>
<version>${dep.slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${dep.slf4j.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
Expand Down
Loading