Skip to content

Commit 180e4ec

Browse files
authored
GH-1039: [Flight] Fix ClassCastException when building FlightClient with domain socket location (#1121)
## What's Changed Fix a `ClassCastException` on`FlightClient.builder().build()` when connecting via a Unix domain socket on Linux (epoll) or macOS (kqueue), by casting to the Netty interface `Channel` instead of the server-specific `ServerChannel`. Also adds netty-transport-native-epoll (Linux) and netty-transport-native-kqueue (macOS) as test-scoped dependencies in flight-core via OS-activated profiles, so the existing `TestServerOptions#domainSocket` test actually runs instead of being skipped everywhere. This change was created with AI assistance (Claude Code). All lines were manually reviewed by a human. The output is not copyrightable subject matter. Closes #1039.
1 parent 522b0a2 commit 180e4ec

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

‎flight/flight-core/pom.xml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,41 @@ under the License.
202202
</plugin>
203203
</plugins>
204204
</build>
205+
206+
<profiles>
207+
<profile>
208+
<id>native-epoll-test</id>
209+
<activation>
210+
<os>
211+
<family>linux</family>
212+
</os>
213+
</activation>
214+
<dependencies>
215+
<dependency>
216+
<groupId>io.netty</groupId>
217+
<artifactId>netty-transport-native-epoll</artifactId>
218+
<version>${dep.netty-bom.version}</version>
219+
<classifier>${os.detected.classifier}</classifier>
220+
<scope>test</scope>
221+
</dependency>
222+
</dependencies>
223+
</profile>
224+
<profile>
225+
<id>native-kqueue-test</id>
226+
<activation>
227+
<os>
228+
<family>mac</family>
229+
</os>
230+
</activation>
231+
<dependencies>
232+
<dependency>
233+
<groupId>io.netty</groupId>
234+
<artifactId>netty-transport-native-kqueue</artifactId>
235+
<version>${dep.netty-bom.version}</version>
236+
<classifier>${os.detected.classifier}</classifier>
237+
<scope>test</scope>
238+
</dependency>
239+
</dependencies>
240+
</profile>
241+
</profiles>
205242
</project>

‎flight/flight-core/src/main/java/org/apache/arrow/flight/grpc/NettyClientBuilder.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import io.grpc.ManagedChannel;
2020
import io.grpc.netty.GrpcSslContexts;
2121
import io.grpc.netty.NettyChannelBuilder;
22+
import io.netty.channel.Channel;
2223
import io.netty.channel.EventLoopGroup;
23-
import io.netty.channel.ServerChannel;
2424
import io.netty.handler.ssl.SslContextBuilder;
2525
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
2626
import java.io.InputStream;
@@ -151,7 +151,7 @@ public NettyChannelBuilder build() {
151151
// Linux
152152
builder.channelType(
153153
Class.forName("io.netty.channel.epoll.EpollDomainSocketChannel")
154-
.asSubclass(ServerChannel.class));
154+
.asSubclass(Channel.class));
155155
final EventLoopGroup elg =
156156
Class.forName("io.netty.channel.epoll.EpollEventLoopGroup")
157157
.asSubclass(EventLoopGroup.class)
@@ -162,7 +162,7 @@ public NettyChannelBuilder build() {
162162
// BSD
163163
builder.channelType(
164164
Class.forName("io.netty.channel.kqueue.KQueueDomainSocketChannel")
165-
.asSubclass(ServerChannel.class));
165+
.asSubclass(Channel.class));
166166
final EventLoopGroup elg =
167167
Class.forName("io.netty.channel.kqueue.KQueueEventLoopGroup")
168168
.asSubclass(EventLoopGroup.class)

0 commit comments

Comments
 (0)