File tree Expand file tree Collapse file tree 2 files changed +5
-21
lines changed
main/java/com/timgroup/statsd
test/java/com/timgroup/statsd Expand file tree Collapse file tree 2 files changed +5
-21
lines changed Original file line number Diff line number Diff line change 99import java .nio .ByteBuffer ;
1010import java .nio .ByteOrder ;
1111import java .nio .channels .SocketChannel ;
12+ import java .lang .reflect .Method ;
1213
1314/**
1415 * A ClientChannel for Unix domain sockets.
@@ -105,16 +106,7 @@ private void connect() throws IOException {
105106 }
106107
107108 private void connectJdkSocket (long deadline ) throws IOException {
108- String socketPath ;
109- if (address instanceof UnixSocketAddress ) {
110- UnixSocketAddress unixAddr = (UnixSocketAddress ) address ;
111- socketPath = unixAddr .path ();
112- } else {
113- socketPath = address .toString ();
114- if (socketPath .startsWith ("file://" ) || socketPath .startsWith ("unix://" )) {
115- socketPath = socketPath .substring (7 );
116- }
117- }
109+ String socketPath = address .toString ();
118110
119111 try {
120112 // Use reflection to avoid compile-time dependency on Java 16+ classes
@@ -128,7 +120,8 @@ private void connectJdkSocket(long deadline) throws IOException {
128120
129121 try {
130122 delegate .configureBlocking (false );
131- if (!delegate .connect ((SocketAddress ) udsAddress )) {
123+ // Use reflection to call the UDS specific connect method
124+ if (!delegate .connect (udsAddress )) {
132125 if (connectionTimeout > 0 && System .nanoTime () > deadline ) {
133126 throw new IOException ("Connection timed out" );
134127 }
Original file line number Diff line number Diff line change @@ -20,16 +20,7 @@ static boolean isJnrAvailable() {
2020 }
2121 }
2222
23- static boolean isJdkUdsAvailable () {
24- try {
25- Class .forName ("java.nio.channels.DatagramChannel" );
26- return true ;
27- } catch (ClassNotFoundException e ) {
28- return false ;
29- }
30- }
31-
3223 static boolean isUdsAvailable () {
33- return (isLinux () || isMac ()) && ( isJdkUdsAvailable () || isJnrAvailable () );
24+ return (isLinux () || isMac ()) && isJnrAvailable ();
3425 }
3526}
You can’t perform that action at this time.
0 commit comments