|
1 | 1 | /******************************************************************************* |
2 | 2 | * Copyright (c) 2016, 2018 Red Hat. |
3 | | - * |
| 3 | + * |
4 | 4 | * This program and the accompanying materials are made |
5 | 5 | * available under the terms of the Eclipse Public License 2.0 |
6 | 6 | * which is available at https://www.eclipse.org/legal/epl-2.0/ |
|
14 | 14 |
|
15 | 15 | import java.io.File; |
16 | 16 | import java.io.IOException; |
| 17 | +import java.net.UnixDomainSocketAddress; |
| 18 | +import java.nio.channels.SocketChannel; |
| 19 | +import java.nio.file.Path; |
17 | 20 | import java.util.Arrays; |
18 | 21 | import java.util.Collections; |
19 | 22 | import java.util.List; |
20 | 23 |
|
21 | 24 | import org.eclipse.linuxtools.docker.core.IDockerConnectionSettings; |
22 | 25 | import org.eclipse.linuxtools.docker.core.IDockerConnectionSettingsProvider; |
23 | 26 |
|
24 | | -import jnr.unixsocket.UnixSocketAddress; |
25 | | -import jnr.unixsocket.UnixSocketChannel; |
26 | | - |
27 | | -public class DefaultUnixConnectionSettingsProvider implements IDockerConnectionSettingsProvider { |
| 27 | +public class DefaultUnixConnectionSettingsProvider |
| 28 | + implements IDockerConnectionSettingsProvider { |
28 | 29 |
|
29 | 30 | @Override |
30 | 31 | public List<IDockerConnectionSettings> getConnectionSettings() { |
31 | | - final File unixSocketFile = new File("/var/run/docker.sock"); //$NON-NLS-1$ |
| 32 | + final Path unixSocketPath = Path.of("/var/run/docker.sock"); //$NON-NLS-1$ |
| 33 | + File unixSocketFile = unixSocketPath.toFile(); |
32 | 34 | if (unixSocketFile.exists() && unixSocketFile.canRead() |
33 | 35 | && unixSocketFile.canWrite()) { |
34 | | - final UnixSocketAddress address = new UnixSocketAddress( |
35 | | - unixSocketFile); |
36 | | - try (final UnixSocketChannel channel = UnixSocketChannel |
37 | | - .open(address)) { |
| 36 | + final UnixDomainSocketAddress address = UnixDomainSocketAddress |
| 37 | + .of(unixSocketPath); |
| 38 | + try (final SocketChannel channel = SocketChannel.open(address)) { |
38 | 39 | // assume socket works |
39 | 40 | final UnixSocketConnectionSettings socket = new UnixSocketConnectionSettings( |
40 | 41 | DefaultDockerConnectionSettingsFinder.Defaults.DEFAULT_UNIX_SOCKET_PATH); |
|
0 commit comments