Skip to content

Commit 985fee2

Browse files
author
Marcus Linke
committed
1 parent 96c4f53 commit 985fee2

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

pom.xml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<!-- test dependencies -->
7575
<logback.version>1.1.7</logback.version>
7676
<testng.version>6.9.10</testng.version>
77-
<netty.version>4.1.3.Final</netty.version>
77+
<netty.version>4.1.7.Final-SNAPSHOT</netty.version>
7878
<hamcrest.library.version>1.3</hamcrest.library.version>
7979
<hamcrest.jpa-matchers>1.8</hamcrest.jpa-matchers>
8080
<lambdaj.version>2.3.3</lambdaj.version>
@@ -87,6 +87,9 @@
8787
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
8888
<maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
8989
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
90+
91+
<epoll.classifier>macos-x86_64</epoll.classifier>
92+
9093
</properties>
9194

9295
<dependencies>
@@ -246,14 +249,38 @@
246249
<artifactId>netty-transport-native-epoll</artifactId>
247250
<version>${netty.version}</version>
248251
<classifier>linux-x86_64</classifier>
252+
<exclusions>
253+
<exclusion>
254+
<groupId>io.netty</groupId>
255+
<artifactId>netty-transport-native-unix-common</artifactId>
256+
</exclusion>
257+
</exclusions>
258+
</dependency>
259+
<dependency>
260+
<groupId>io.netty</groupId>
261+
<artifactId>netty-transport-native-kqueue</artifactId>
262+
<version>${netty.version}</version>
263+
<classifier>osx-x86_64</classifier>
264+
<exclusions>
265+
<exclusion>
266+
<groupId>io.netty</groupId>
267+
<artifactId>netty-transport-native-unix-common</artifactId>
268+
</exclusion>
269+
</exclusions>
270+
</dependency>
271+
<dependency>
272+
<groupId>io.netty</groupId>
273+
<artifactId>netty-transport-native-unix-common</artifactId>
274+
<version>${netty.version}</version>
275+
<classifier>osx-x86_64</classifier>
249276
</dependency>
250277
<dependency>
251278
<groupId>junit</groupId>
252279
<artifactId>junit</artifactId>
253280
<version>4.12</version>
254281
<scope>test</scope>
255282
</dependency>
256-
<dependency>
283+
<dependency>
257284
<groupId>com.github.jnr</groupId>
258285
<artifactId>jnr-unixsocket</artifactId>
259286
<version>0.12</version>
@@ -277,13 +304,13 @@
277304
</distributionManagement>
278305

279306
<build>
280-
<!-- <extensions> -->
281-
<!-- <extension> -->
282-
<!-- <groupId>kr.motd.maven</groupId> -->
283-
<!-- <artifactId>os-maven-plugin</artifactId> -->
284-
<!-- <version>1.2.3.Final</version> -->
285-
<!-- </extension> -->
286-
<!-- </extensions> -->
307+
<extensions>
308+
<extension>
309+
<groupId>kr.motd.maven</groupId>
310+
<artifactId>os-maven-plugin</artifactId>
311+
<version>1.4.0.Final</version>
312+
</extension>
313+
</extensions>
287314
<pluginManagement>
288315
<plugins>
289316

@@ -430,7 +457,7 @@
430457
<perCoreThreadCount>true</perCoreThreadCount>
431458
<threadCount>1</threadCount>
432459
<groups>integration</groups>
433-
<excludedGroups>integration-auth</excludedGroups>
460+
<excludedGroups>integration-auth</excludedGroups>
434461
<includes>
435462
<include>**/*ExecTest.java</include>
436463
</includes>
@@ -494,7 +521,7 @@
494521
<failOnViolation>true</failOnViolation>
495522
<logViolationsToConsole>true</logViolationsToConsole>
496523
<linkXRef>false</linkXRef>
497-
<!-- if some IDE has integration and requires other place, propose
524+
<!-- if some IDE has integration and requires other place, propose
498525
it -->
499526
<configLocation>
500527
src/test/resources/checkstyle/checkstyle-config.xml

src/main/java/com/github/dockerjava/netty/NettyDockerCmdExecFactory.java

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.net.InetAddress;
77
import java.net.InetSocketAddress;
88
import java.net.SocketAddress;
9-
import java.nio.channels.spi.SelectorProvider;
109
import java.security.Security;
1110

1211
import javax.net.ssl.SSLEngine;
@@ -122,20 +121,19 @@
122121
import com.github.dockerjava.netty.exec.WaitContainerCmdExec;
123122

124123
import io.netty.bootstrap.Bootstrap;
125-
import io.netty.channel.ChannelFactory;
126124
import io.netty.channel.ChannelInitializer;
127125
import io.netty.channel.EventLoopGroup;
126+
import io.netty.channel.kqueue.KQueueDomainSocketChannel;
127+
import io.netty.channel.kqueue.KQueueEventLoopGroup;
128128
import io.netty.channel.nio.NioEventLoopGroup;
129129
import io.netty.channel.socket.DuplexChannel;
130130
import io.netty.channel.socket.SocketChannel;
131131
import io.netty.channel.socket.nio.NioSocketChannel;
132+
import io.netty.channel.unix.DomainSocketAddress;
132133
import io.netty.handler.codec.http.HttpClientCodec;
133134
import io.netty.handler.logging.LoggingHandler;
134135
import io.netty.handler.ssl.SslHandler;
135136
import io.netty.util.concurrent.DefaultThreadFactory;
136-
import jnr.enxio.channels.NativeSelectorProvider;
137-
import jnr.unixsocket.UnixSocketAddress;
138-
import jnr.unixsocket.UnixSocketChannel;
139137

140138
/**
141139
* Experimental implementation of {@link DockerCmdExecFactory} that supports http connection hijacking that is needed to pass STDIN to the
@@ -221,24 +219,11 @@ private class UnixDomainSocketInitializer implements NettyInitializer {
221219

222220
@Override
223221
public EventLoopGroup init(Bootstrap bootstrap, DockerClientConfig dockerClientConfig) {
224-
final SelectorProvider nativeSelectorProvider = NativeSelectorProvider.getInstance();
225222

226-
EventLoopGroup nioEventLoopGroup = new NioEventLoopGroup(0,
227-
new DefaultThreadFactory(threadPrefix), nativeSelectorProvider);
223+
EventLoopGroup nioEventLoopGroup = new KQueueEventLoopGroup(0,
224+
new DefaultThreadFactory(threadPrefix));
228225

229-
ChannelFactory<NioSocketChannel> factory = new ChannelFactory<NioSocketChannel>() {
230-
231-
@Override
232-
public NioSocketChannel newChannel() {
233-
try {
234-
return new NioSocketChannel(UnixSocketChannel.create());
235-
} catch (IOException e) {
236-
throw new RuntimeException();
237-
}
238-
}
239-
};
240-
241-
bootstrap.group(nioEventLoopGroup).channelFactory(factory)
226+
bootstrap.group(nioEventLoopGroup).channel(KQueueDomainSocketChannel.class)
242227
.handler(new ChannelInitializer<SocketChannel>() {
243228
@Override
244229
protected void initChannel(final SocketChannel channel) throws Exception {
@@ -257,7 +242,7 @@ public DuplexChannel connect(Bootstrap bootstrap) throws InterruptedException {
257242
throw new RuntimeException("socket not found: " + path);
258243
}
259244

260-
UnixSocketAddress address = new UnixSocketAddress(path);
245+
DomainSocketAddress address = new DomainSocketAddress(path);
261246

262247
return (DuplexChannel) bootstrap.connect(address).sync().channel();
263248
}

0 commit comments

Comments
 (0)