Skip to content

Commit 67ef5ab

Browse files
authored
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.
1 parent 301dc90 commit 67ef5ab

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImpl.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public Object get(final Properties properties) {
333333
*/
334334
public Boolean getBoolean(final Properties properties) {
335335
final String valueFromProperties = String.valueOf(get(properties));
336-
return valueFromProperties.equals("1") || valueFromProperties.equals("true");
336+
return valueFromProperties.equals("1") || valueFromProperties.equalsIgnoreCase("true");
337337
}
338338

339339
/**

‎flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/utils/ArrowFlightConnectionConfigImplTest.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.junit.jupiter.params.ParameterizedTest;
4040
import org.junit.jupiter.params.provider.Arguments;
4141
import org.junit.jupiter.params.provider.MethodSource;
42+
import org.junit.jupiter.params.provider.ValueSource;
4243

4344
public final class ArrowFlightConnectionConfigImplTest {
4445

@@ -71,6 +72,22 @@ public void testGetProperty(
7172
arrowFlightConnectionConfigFunction.apply(arrowFlightConnectionConfig), is(expected));
7273
}
7374

75+
@ParameterizedTest
76+
@ValueSource(strings = {"true", "TRUE", "True", "tRuE", "1"})
77+
public void testUseEncryptionAcceptsTruthyValuesCaseInsensitively(String value) {
78+
// A connection string value like "TRUE" must enable TLS. Parsing it as false would
79+
// silently downgrade the connection to plaintext and leak credentials.
80+
properties.put(USE_ENCRYPTION.camelName(), value);
81+
assertThat(arrowFlightConnectionConfig.useEncryption(), is(true));
82+
}
83+
84+
@ParameterizedTest
85+
@ValueSource(strings = {"false", "FALSE", "0", ""})
86+
public void testUseEncryptionRejectsFalsyValues(String value) {
87+
properties.put(USE_ENCRYPTION.camelName(), value);
88+
assertThat(arrowFlightConnectionConfig.useEncryption(), is(false));
89+
}
90+
7491
public static Stream<Arguments> provideParameters() {
7592
int port = RANDOM.nextInt(Short.toUnsignedInt(Short.MAX_VALUE));
7693
boolean useEncryption = RANDOM.nextBoolean();

0 commit comments

Comments
 (0)