diff --git a/test/micro/org/openjdk/bench/java/net/UnixSocketChannelReadWrite.java b/test/micro/org/openjdk/bench/java/net/UnixSocketChannelReadWrite.java index 9e75b0d556c..8a3f24cc638 100644 --- a/test/micro/org/openjdk/bench/java/net/UnixSocketChannelReadWrite.java +++ b/test/micro/org/openjdk/bench/java/net/UnixSocketChannelReadWrite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ import java.nio.channels.SocketChannel; import java.nio.file.*; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import org.openjdk.jmh.annotations.*; @@ -49,22 +48,10 @@ public class UnixSocketChannelReadWrite { private ReadThread rt; private ByteBuffer bb = ByteBuffer.allocate(1); - private static volatile String tempDir; - private static final AtomicInteger count = new AtomicInteger(0); private volatile Path socket; - static { - try { - Path p = Files.createTempDirectory("readWriteTest"); - tempDir = p.toString(); - } catch (IOException e) { - tempDir = null; - } - } - private ServerSocketChannel getServerSocketChannel() throws IOException { - int next = count.incrementAndGet(); - socket = Paths.get(tempDir, Integer.toString(next)); + socket = Files.createTempDirectory(UnixSocketChannelReadWrite.class.getSimpleName()).resolve("sock"); UnixDomainSocketAddress addr = UnixDomainSocketAddress.of(socket); ServerSocketChannel c = ServerSocketChannel.open(StandardProtocolFamily.UNIX); c.bind(addr); @@ -90,7 +77,7 @@ public void afterRun() throws IOException, InterruptedException { s2.close(); ssc.close(); Files.delete(socket); - Files.delete(Path.of(tempDir)); + Files.delete(socket.getParent()); rt.join(); }