Skip to content

Commit 18de621

Browse files
authored
GH-1004: [JDBC] Fix NPE in ArrowFlightJdbcDriver#connect​(final String url, final Properties info) (#1005)
## What's Changed `ArrowFlightJdbcDriver.connect(final String url, final Properties info)` now properly ignores a null value for `info`, obtaining the properties solely from the URL. Closes #1004.
1 parent 6ffb2d0 commit 18de621

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDriver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public Logger getParentLogger() {
7575
public ArrowFlightConnection connect(final String url, final Properties info)
7676
throws SQLException {
7777
final Properties properties = new Properties(info);
78-
properties.putAll(info);
78+
if (info != null) {
79+
properties.putAll(info);
80+
}
7981

8082
if (url != null) {
8183
final Optional<Map<Object, Object>> maybeProperties = getUrlsArgs(url);

flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcDriverTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,30 @@ public void testConnectWithInsensitiveCasePropertyKeys2() throws Exception {
201201
}
202202
}
203203

204+
/**
205+
* Tests whether the {@link ArrowFlightJdbcDriver} can establish a successful connection to the
206+
* Arrow Flight client when provided with null properties.
207+
*/
208+
@Test
209+
public void testConnectWithNullProperties() throws Exception {
210+
final Driver driver = new ArrowFlightJdbcDriver();
211+
try (Connection connection =
212+
driver.connect(
213+
"jdbc:arrow-flight://"
214+
+ dataSource.getConfig().getHost()
215+
+ ":"
216+
+ dataSource.getConfig().getPort()
217+
+ "?"
218+
+ "useEncryption=false"
219+
+ "&user="
220+
+ dataSource.getConfig().getUser()
221+
+ "&password="
222+
+ dataSource.getConfig().getPassword(),
223+
null)) {
224+
assertTrue(connection.isValid(300));
225+
}
226+
}
227+
204228
/**
205229
* Tests whether an exception is thrown upon attempting to connect to a malformed URI.
206230
*

0 commit comments

Comments
 (0)