File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 3030import org .newsclub .net .unix .AFUNIXServerSocket ;
3131import org .newsclub .net .unix .AFUNIXSocket ;
3232
33- import java .io .File ;
3433import java .io .IOException ;
3534import java .io .InputStream ;
3635import java .io .OutputStream ;
@@ -57,7 +56,7 @@ public final class UnixDomainProxyServer {
5756 public UnixDomainProxyServer (final int port ) {
5857 this .port = port ;
5958 this .executorService = Executors .newCachedThreadPool ();
60- this .socketPath = ( new File ( "proxy.sock" )). toPath ();
59+ this .socketPath = createTempSocketPath ();
6160 }
6261
6362 public void start () {
@@ -126,6 +125,16 @@ private void serveRequests(final AFUNIXServerSocket server) throws IOException {
126125 }
127126 }
128127
128+ private static Path createTempSocketPath () {
129+ try {
130+ final Path tempFile = Files .createTempFile ("uds" , ".sock" );
131+ Files .deleteIfExists (tempFile );
132+ return tempFile ;
133+ } catch (final IOException ex ) {
134+ throw new RuntimeException (ex );
135+ }
136+ }
137+
129138 private Void pipe (final Socket inputSocket , final Socket outputSocket ) {
130139 try (
131140 final InputStream in = inputSocket .getInputStream ();
You can’t perform that action at this time.
0 commit comments