Skip to content

8351601: [JMH] test UnixSocketChannelReadWrite failed for 2 threads config #3689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.*;

Expand All @@ -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);
Expand All @@ -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();
}

Expand Down