Skip to content
Merged
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 @@ -139,7 +139,12 @@ public NettyChannelBuilder build() {
case LocationSchemes.GRPC_INSECURE:
case LocationSchemes.GRPC_TLS:
{
builder = NettyChannelBuilder.forAddress(location.toSocketAddress());
final int port = location.getUri().getPort();
if (port < 0 || port > 65535) {
throw new IllegalArgumentException(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, this is the same exception class that gRPC used to throw for us?

@ennuite ennuite Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it wasn't gRPC that used to throw for us.

Details:
location.toSocketAddress()) is at

return new InetSocketAddress(uri.getHost(), uri.getPort());

The call to InetSocketAddress(String hostname, int port) throws IllegalArgumentException when the port is smaller than 0 or greater than 65535 (you can find that in the linked Javadoc).

"Invalid port " + port + ": must be between 0 and 65535.");
}
builder = NettyChannelBuilder.forAddress(location.getUri().getHost(), port);
break;
}
case LocationSchemes.GRPC_DOMAIN_SOCKET:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@
import static org.junit.jupiter.api.Assertions.fail;

import com.google.protobuf.Message;
import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import org.apache.arrow.driver.jdbc.authentication.UserPasswordAuthentication;
import org.apache.arrow.driver.jdbc.client.ArrowFlightSqlClientHandler;
Expand Down Expand Up @@ -768,4 +775,39 @@ public void testResultSetsFromDatabaseMetadataClosedOnConnectionClose() throws E
assertTrue(resultSets[i].isClosed());
}
}

@Test
public void testJdbcDriverConsultsProxySelectorForTcpConnections() throws Exception {
AtomicBoolean consulted = new AtomicBoolean(false);
ProxySelector original = ProxySelector.getDefault();
ProxySelector.setDefault(
new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
consulted.set(true);
return original.select(uri);
}

@Override
public void connectFailed(URI uri, SocketAddress sa, IOException e) {}
});

try {
final Properties properties = new Properties();
properties.put(ArrowFlightConnectionProperty.USER.camelName(), userTest);
properties.put(ArrowFlightConnectionProperty.PASSWORD.camelName(), passTest);
properties.put("useEncryption", false);

DriverManager.getConnection(
"jdbc:arrow-flight-sql://localhost:" + FLIGHT_SERVER_TEST_EXTENSION.getPort(),
properties)
.close();

assertTrue(
consulted.get(),
"JDBC driver must consult ProxySelector so JVM proxy settings are respected");
} finally {
ProxySelector.setDefault(original);
}
}
}
Loading