diff --git a/java/flight/flight-jdbc-driver/jdbc-spotbugs-exclude.xml b/java/flight/flight-jdbc-driver/jdbc-spotbugs-exclude.xml
new file mode 100644
index 000000000000..c257b39ea2bf
--- /dev/null
+++ b/java/flight/flight-jdbc-driver/jdbc-spotbugs-exclude.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/java/flight/flight-jdbc-driver/pom.xml b/java/flight/flight-jdbc-driver/pom.xml
index 85af74730e9d..480055e95f03 100644
--- a/java/flight/flight-jdbc-driver/pom.xml
+++ b/java/flight/flight-jdbc-driver/pom.xml
@@ -79,16 +79,6 @@
${arrow.vector.classifier}
-
- org.apache.calcite.avatica
- avatica
-
-
-
- org.bouncycastle
- bcpkix-jdk15on
-
-
com.google.guava
guava
@@ -142,6 +132,17 @@
flight-sql
${project.version}
+
+
+ org.apache.calcite.avatica
+ avatica
+ 1.18.0
+
+
+ org.bouncycastle
+ bcpkix-jdk15on
+ 1.61
+
@@ -171,6 +172,7 @@
com.github.spotbugs
spotbugs-maven-plugin
+ jdbc-spotbugs-exclude.xml
true
target/spotbugs
diff --git a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java
index fa2fb389b803..f2579ea03e9f 100644
--- a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java
+++ b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowDatabaseMetadata.java
@@ -729,8 +729,8 @@ private T getSqlInfoAndCacheIfCacheIsEmpty(final SqlInfo sqlInfoCommand,
final Class desiredType)
throws SQLException {
final ArrowFlightConnection connection = getConnection();
- final FlightInfo sqlInfo = connection.getClientHandler().getSqlInfo();
if (cachedSqlInfo.isEmpty()) {
+ final FlightInfo sqlInfo = connection.getClientHandler().getSqlInfo();
synchronized (cachedSqlInfo) {
if (cachedSqlInfo.isEmpty()) {
try (final ResultSet resultSet =
diff --git a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightConnection.java b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightConnection.java
index f5e5a3c44932..76fe70c3b63f 100644
--- a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightConnection.java
+++ b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightConnection.java
@@ -104,7 +104,11 @@ private static ArrowFlightSqlClientHandler createNewClientHandler(
.withCallOptions(config.toCallOption())
.build();
} catch (final SQLException e) {
- allocator.close();
+ try {
+ allocator.close();
+ } catch (final Exception allocatorCloseEx) {
+ e.addSuppressed(allocatorCloseEx);
+ }
throw e;
}
}
@@ -149,7 +153,9 @@ synchronized ExecutorService getExecutorService() {
@Override
public Properties getClientInfo() {
- return info;
+ final Properties copy = new Properties();
+ copy.putAll(info);
+ return copy;
}
@Override
diff --git a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcCursor.java b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcCursor.java
index 3a552256baf7..45c23e4d5298 100644
--- a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcCursor.java
+++ b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcCursor.java
@@ -78,7 +78,7 @@ private Accessor createAccessor(FieldVector vector) {
*/
@Override
protected Getter createGetter(int column) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("Not allowed.");
}
@Override
diff --git a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDataSource.java b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDataSource.java
index 289887067bdb..6e60bd95d590 100644
--- a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDataSource.java
+++ b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDataSource.java
@@ -103,17 +103,17 @@ public T unwrap(Class aClass) throws SQLException {
}
@Override
- public boolean isWrapperFor(Class> aClass) throws SQLException {
+ public boolean isWrapperFor(Class> aClass) {
return false;
}
@Override
- public PrintWriter getLogWriter() throws SQLException {
+ public PrintWriter getLogWriter() {
return this.logWriter;
}
@Override
- public void setLogWriter(PrintWriter logWriter) throws SQLException {
+ public void setLogWriter(PrintWriter logWriter) {
this.logWriter = logWriter;
}
@@ -123,12 +123,12 @@ public void setLoginTimeout(int timeout) throws SQLException {
}
@Override
- public int getLoginTimeout() throws SQLException {
+ public int getLoginTimeout() {
return 0;
}
@Override
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ public Logger getParentLogger() {
return Logger.getLogger("ArrowFlightJdbc");
}
}
diff --git a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDriver.java b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDriver.java
index a855b2feb51e..fc15837c4b35 100644
--- a/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDriver.java
+++ b/java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDriver.java
@@ -19,6 +19,7 @@
import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
@@ -47,6 +48,7 @@
public class ArrowFlightJdbcDriver extends UnregisteredDriver {
private static final String CONNECT_STRING_PREFIX = "jdbc:arrow-flight://";
+ private static final String CONNECTION_STRING_EXPECTED = "jdbc:arrow-flight://[host][:port][?param1=value&...]";
private static DriverVersion version;
static {
@@ -81,7 +83,7 @@ public ArrowFlightConnection connect(final String url, final Properties info)
url,
properties,
new RootAllocator(Long.MAX_VALUE));
- } catch (AssertionError | FlightRuntimeException e) {
+ } catch (final FlightRuntimeException e) {
throw new SQLException("Failed to connect.", e);
}
}
@@ -93,41 +95,39 @@ protected String getFactoryClassName(final JdbcVersion jdbcVersion) {
@Override
protected DriverVersion createDriverVersion() {
-
- CreateVersionIfNull:
- {
-
- if (version != null) {
- break CreateVersionIfNull;
+ if (version == null) {
+ final InputStream flightProperties = this.getClass().getResourceAsStream("/properties/flight.properties");
+ if (flightProperties == null) {
+ throw new RuntimeException("Flight Properties not found. Ensure the JAR was built properly.");
}
-
- try (Reader reader = new BufferedReader(new InputStreamReader(
- this.getClass().getResourceAsStream("/properties/flight.properties"),
- StandardCharsets.UTF_8))) {
+ try (final Reader reader = new BufferedReader(new InputStreamReader(flightProperties, StandardCharsets.UTF_8))) {
final Properties properties = new Properties();
properties.load(reader);
- final String parentName = properties
- .getProperty("org.apache.arrow.flight.name");
- final String parentVersion = properties
- .getProperty("org.apache.arrow.flight.version");
+ final String parentName = properties.getProperty("org.apache.arrow.flight.name");
+ final String parentVersion = properties.getProperty("org.apache.arrow.flight.version");
final String[] pVersion = parentVersion.split("\\.");
final int parentMajorVersion = Integer.parseInt(pVersion[0]);
final int parentMinorVersion = Integer.parseInt(pVersion[1]);
- final String childName = properties
- .getProperty("org.apache.arrow.flight.jdbc-driver.name");
- final String childVersion = properties
- .getProperty("org.apache.arrow.flight.jdbc-driver.version");
+ final String childName = properties.getProperty("org.apache.arrow.flight.jdbc-driver.name");
+ final String childVersion = properties.getProperty("org.apache.arrow.flight.jdbc-driver.version");
final String[] cVersion = childVersion.split("\\.");
final int childMajorVersion = Integer.parseInt(cVersion[0]);
final int childMinorVersion = Integer.parseInt(cVersion[1]);
- version = new DriverVersion(childName, childVersion, parentName,
- parentVersion, true, childMajorVersion, childMinorVersion,
- parentMajorVersion, parentMinorVersion);
+ version = new DriverVersion(
+ childName,
+ childVersion,
+ parentName,
+ parentVersion,
+ true,
+ childMajorVersion,
+ childMinorVersion,
+ parentMajorVersion,
+ parentMinorVersion);
} catch (final IOException e) {
throw new RuntimeException("Failed to load driver version.", e);
}
@@ -138,7 +138,7 @@ protected DriverVersion createDriverVersion() {
@Override
public Meta createMeta(final AvaticaConnection connection) {
- return new ArrowFlightMetaImpl((ArrowFlightConnection) connection);
+ return new ArrowFlightMetaImpl(connection);
}
@Override
@@ -147,7 +147,7 @@ protected String getConnectStringPrefix() {
}
@Override
- public boolean acceptsURL(final String url) throws SQLException {
+ public boolean acceptsURL(final String url) {
return Preconditions.checkNotNull(url).startsWith(CONNECT_STRING_PREFIX);
}
@@ -218,7 +218,8 @@ private Map
-
- org.apache.maven
- maven-model
- 3.3.9
-
com.google.flatbuffers
flatbuffers-java
@@ -589,26 +578,6 @@
hamcrest
2.2
-
- org.apache.calcite.avatica
- avatica
- 1.18.0
-
-
- org.bouncycastle
- bcpkix-jdk15on
- 1.61
-
-
- com.google.code.findbugs
- annotations
- 3.0.1
-
-
- org.codehaus.plexus
- plexus-utils
- 3.0.22
-
@@ -664,7 +633,7 @@
junit
junit
- 4.13
+ 4.12
test