Skip to content

Commit

Permalink
Merge pull request spotify#918 from spotify/dxia/upgrade-jnr
Browse files Browse the repository at this point in the history
Upgrade to jnr-unixsocket 0.18
  • Loading branch information
davidxia authored Nov 15, 2017
2 parents e04be81 + 88721f0 commit eeda3db
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 347 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-unixsocket</artifactId>
<version>0.8</version>
<version>0.18</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
Expand Down
342 changes: 0 additions & 342 deletions src/main/java/com/spotify/docker/client/ApacheUnixSocket.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import java.net.SocketTimeoutException;
import java.net.URI;

import jnr.unixsocket.UnixSocket;
import jnr.unixsocket.UnixSocketAddress;
import jnr.unixsocket.UnixSocketChannel;

import org.apache.http.HttpHost;
import org.apache.http.annotation.Contract;
Expand Down Expand Up @@ -63,8 +65,8 @@ public static URI sanitizeUri(final URI uri) {
}

@Override
public Socket createSocket(final HttpContext context) throws IOException {
return new ApacheUnixSocket();
public UnixSocket createSocket(final HttpContext context) throws IOException {
return UnixSocketChannel.open().socket();
}

@Override
Expand All @@ -74,12 +76,16 @@ public Socket connectSocket(final int connectTimeout,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
final HttpContext context) throws IOException {
if (!(socket instanceof UnixSocket)) {
throw new AssertionError("Unexpected socket: " + socket);
}

socket.setSoTimeout(connectTimeout);
try {
socket.connect(new UnixSocketAddress(socketFile), connectTimeout);
socket.getChannel().connect(new UnixSocketAddress(socketFile));
} catch (SocketTimeoutException e) {
throw new ConnectTimeoutException(e, null, remoteAddress.getAddress());
}

return socket;
}
}
Loading

0 comments on commit eeda3db

Please sign in to comment.