You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that JEP-380 has shipped in java 16, we should be able to replace the current usage of junixsocket with SocketChannel and UnixDomainSocketAddress for users of java 16 and above.
This is most likely an oversimplification, but for simple queries like ping, info, listImage and listContainers this code seemed to work pretty well.
publicclassJavaUnixSocketextendsSocket {
privatefinalSocketChannelsocketChannel;
publicUnixSocket(Stringpath) throwsIOException {
this.socketChannel = SocketChannel.open(UnixDomainSocketAddress.of(path));
}
publicstaticJavaUnixSocketget(Stringpath) throwsIOException {
returnnewJavaUnixSocket(path);
}
@OverridepublicInputStreamgetInputStream() throwsIOException {
if (isClosed())
thrownewSocketException("Socket is closed");
if (!isConnected())
thrownewSocketException("Socket is not connected");
if (isInputShutdown())
thrownewSocketException("Socket input is shutdown");
returnChannels.newInputStream(socketChannel);
}
@OverridepublicOutputStreamgetOutputStream() throwsIOException {
if (isClosed())
thrownewSocketException("Socket is closed");
if (!isConnected())
thrownewSocketException("Socket is not connected");
if (isOutputShutdown())
thrownewSocketException("Socket output is shutdown");
returnChannels.newOutputStream(socketChannel);
}
@Overridepublicvoidclose() throwsIOException {
super.close();
this.socketChannel.close();
}
}
Alternatively, reflectively calling UnixDomainSocketAddress.of(path) might be enough, since the rest of the functions should be java 8 compatible.
Thanks for checking, looks very promising! I am setting up Java 16 on my machine, but could you please check, perhaps there is some Java 8-compatible factory that calls UnixDomainSocketAddress.of(path), so that we can avoid figuring out the linking question? Thanks in advance!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
Sineaggi commentedon May 11, 2021
This is most likely an oversimplification, but for simple queries like ping, info, listImage and listContainers this code seemed to work pretty well.
Alternatively, reflectively calling
UnixDomainSocketAddress.of(path)might be enough, since the rest of the functions should be java 8 compatible.bsideup commentedon May 11, 2021
Hi @Sineaggi,
Thanks for checking, looks very promising! I am setting up Java 16 on my machine, but could you please check, perhaps there is some Java 8-compatible factory that calls
UnixDomainSocketAddress.of(path), so that we can avoid figuring out the linking question? Thanks in advance!Sineaggi commentedon May 11, 2021
A quick glance at the docs and Find Usages in Intellij unfortunately doesn't reveal any factory methods.
stale commentedon Aug 9, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
bsideup commentedon Sep 13, 2021
Implemented in #1627