This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-java.git
The following commit(s) were added to refs/heads/main by this push:
new 67ef5abf3 GH-1357: parse Flight SQL JDBC boolean properties
case-insensitively (#1358)
67ef5abf3 is described below
commit 67ef5abf308a7a158c4fa8eeebb72b87ca5a6f97
Author: Abdul Rawoof Khan <[email protected]>
AuthorDate: Sat Oct 31 12:27:55 2026 +0530
GH-1357: parse Flight SQL JDBC boolean properties case-insensitively (#1358)
## What's Changed
`ArrowFlightConnectionProperty.getBoolean` only treated `1` and the
exact lowercase `true` as true, and connection-string values are not
normalized, so `useEncryption=TRUE` (or `True`) parsed as false. Since
`useEncryption` defaults to true and drives `withEncryption`, that
silently downgraded the connection to plaintext and sent the auth
handshake and credentials in the clear. This compares `true`
case-insensitively while still honoring `1`, matching how JDBC drivers
normally parse boolean options.
Closes #1357.
---
.../jdbc/utils/ArrowFlightConnectionConfigImpl.java | 2 +-
.../jdbc/utils/ArrowFlightConnectionConfigImplTest.java | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git
a/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImpl.java
b/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImpl.java
index d0ba74dbc..812f189bc 100644
---
a/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImpl.java
+++
b/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImpl.java
@@ -333,7 +333,7 @@ public final class ArrowFlightConnectionConfigImpl extends
ConnectionConfigImpl
*/
public Boolean getBoolean(final Properties properties) {
final String valueFromProperties = String.valueOf(get(properties));
- return valueFromProperties.equals("1") ||
valueFromProperties.equals("true");
+ return valueFromProperties.equals("1") ||
valueFromProperties.equalsIgnoreCase("true");
}
/**
diff --git
a/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImplTest.java
b/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImplTest.java
index ecce7708c..ef7126d1c 100644
---
a/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImplTest.java
+++
b/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImplTest.java
@@ -39,6 +39,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.jupiter.params.provider.ValueSource;
public final class ArrowFlightConnectionConfigImplTest {
@@ -71,6 +72,22 @@ public final class ArrowFlightConnectionConfigImplTest {
arrowFlightConnectionConfigFunction.apply(arrowFlightConnectionConfig),
is(expected));
}
+ @ParameterizedTest
+ @ValueSource(strings = {"true", "TRUE", "True", "tRuE", "1"})
+ public void testUseEncryptionAcceptsTruthyValuesCaseInsensitively(String
value) {
+ // A connection string value like "TRUE" must enable TLS. Parsing it as
false would
+ // silently downgrade the connection to plaintext and leak credentials.
+ properties.put(USE_ENCRYPTION.camelName(), value);
+ assertThat(arrowFlightConnectionConfig.useEncryption(), is(true));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"false", "FALSE", "0", ""})
+ public void testUseEncryptionRejectsFalsyValues(String value) {
+ properties.put(USE_ENCRYPTION.camelName(), value);
+ assertThat(arrowFlightConnectionConfig.useEncryption(), is(false));
+ }
+
public static Stream<Arguments> provideParameters() {
int port = RANDOM.nextInt(Short.toUnsignedInt(Short.MAX_VALUE));
boolean useEncryption = RANDOM.nextBoolean();