Skip to content
Open
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 @@ -140,9 +140,9 @@ public NettyChannelBuilder build() {
case LocationSchemes.GRPC_TLS:
{
final int port = location.getUri().getPort();
if (port < 0 || port > 65535) {
if (port < 1 || port > 65535) {
throw new IllegalArgumentException(
"Invalid port " + port + ": must be between 0 and 65535.");
"Invalid port " + port + ": must be between 1 and 65535.");
}
builder = NettyChannelBuilder.forAddress(location.getUri().getHost(), port);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public void testGetNonAuthenticatedEncryptedClientNoAuth() throws Exception {
try (ArrowFlightSqlClientHandler client =
new ArrowFlightSqlClientHandler.Builder()
.withHost(FLIGHT_SERVER_TEST_EXTENSION.getHost())
.withPort(FLIGHT_SERVER_TEST_EXTENSION.getPort())
.withTlsRootCertificates(tlsRootCertsPath)
.withClientCertificate(clientMTlsCertPath)
.withClientKey(clientMTlsKeyPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

/** Tests for {@link Connection}. */
public class ConnectionTest {
Expand Down Expand Up @@ -204,21 +206,20 @@ public void testGetBasicClientAuthenticatedShouldOpenConnection() throws Excepti
}

/**
* Checks if the exception IllegalArgumentException is thrown when trying to establish an
* unencrypted connection providing with an invalid port.
*
* @throws SQLException on error.
* Checks if a SQLException is thrown when trying to establish an unencrypted connection with an
* invalid port.
*/
@Test
public void testUnencryptedConnectionProvidingInvalidPort() throws Exception {
@ParameterizedTest
@ValueSource(ints = {0, -1, 65536, 65537})
public void testUnencryptedConnectionProvidingInvalidPort(int invalidPort) {
final Properties properties = new Properties();

properties.put(ArrowFlightConnectionProperty.HOST.camelName(), "localhost");
properties.put(ArrowFlightConnectionProperty.USER.camelName(), userTest);
properties.put(ArrowFlightConnectionProperty.PASSWORD.camelName(), passTest);
properties.put(ArrowFlightConnectionProperty.USE_ENCRYPTION.camelName(), false);
final String invalidUrl =
"jdbc:arrow-flight-sql://" + FLIGHT_SERVER_TEST_EXTENSION.getHost() + ":" + 65537;
"jdbc:arrow-flight-sql://" + FLIGHT_SERVER_TEST_EXTENSION.getHost() + ":" + invalidPort;

assertThrows(
SQLException.class,
Expand All @@ -240,6 +241,7 @@ public void testGetBasicClientNoAuthShouldOpenConnection() throws Exception {
try (ArrowFlightSqlClientHandler client =
new ArrowFlightSqlClientHandler.Builder()
.withHost(FLIGHT_SERVER_TEST_EXTENSION.getHost())
.withPort(FLIGHT_SERVER_TEST_EXTENSION.getPort())
.withBufferAllocator(allocator)
.withEncryption(false)
.build()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void testGetNonAuthenticatedEncryptedClientNoAuth() throws Exception {
try (ArrowFlightSqlClientHandler client =
new ArrowFlightSqlClientHandler.Builder()
.withHost(FLIGHT_SERVER_TEST_EXTENSION.getHost())
.withPort(FLIGHT_SERVER_TEST_EXTENSION.getPort())
.withTlsRootCertificates(tlsRootCertsPath)
.withBufferAllocator(allocator)
.withEncryption(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public void testGetNonAuthenticatedEncryptedClientNoAuth() throws Exception {
try (ArrowFlightSqlClientHandler client =
new ArrowFlightSqlClientHandler.Builder()
.withHost(FLIGHT_SERVER_TEST_EXTENSION.getHost())
.withPort(FLIGHT_SERVER_TEST_EXTENSION.getPort())
.withSystemTrustStore(false)
.withTrustStorePath(trustStorePath)
.withTrustStorePassword(trustStorePass)
Expand Down
Loading