8000 Don't swallow IOException caused by opening socket (#2041) · docker-java/docker-java@721f09f · GitHub
[go: up one dir, main page]

Skip to content

Commit 721f09f

Browse files
authored
Don't swallow IOException caused by opening socket (#2041)
Add additional context to socket exception
1 parent 61dc042 commit 721f09f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

docker-java-transport-okhttp/src/main/java/com/github/dockerjava/okhttp/UnixSocketFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public Socket createSocket() {
2020
try {
2121
return UnixSocket.get(socketPath);
2222
} catch (IOException e) {
23-
throw new RuntimeException(e);
23+
throw new RuntimeException("Failed create socket with path " + socketPath, e);
2424
}
2525
}
2626

docker-java-transport/src/main/java/com/github/dockerjava/transport/UnixSocket.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.io.InputStream;
55
import java.io.OutputStream;
6+
import java.lang.reflect.InvocationTargetException;
67
import java.net.Socket;
78
import java.net.SocketAddress;
89
import java.net.SocketException;
@@ -24,7 +25,8 @@ public class UnixSocket extends AbstractSocket {
2425
public static Socket get(String path) throws IOException {
2526
try {
2627
return new UnixSocket(path);
27-
} catch (Exception e) {
28+
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
29+
IllegalAccessException e) {
2830
//noinspection deprecation
2931
return DomainSocket.get(path);
3032
}
@@ -34,7 +36,8 @@ public static Socket get(String path) throws IOException {
3436

3537
private final SocketChannel socketChannel;
3638

37-
private UnixSocket(String path) throws Exception {
39+
private UnixSocket(String path) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException,
40+
IllegalAccessException, IOException {
3841
Class<?> unixDomainSocketAddress = Class.forName("java.net.UnixDomainSocketAddress");
< 4239 /code>
3942
this.socketAddress =
4043
(SocketAddress) unixDomainSocketAddress.getMethod("of", String.class)

0 commit comments

Comments
 (0)
0