Skip to content

Commit d57767e

Browse files
committed
Remove modern Thread code
1 parent 5207688 commit d57767e

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

test/jdk/java/nio/channels/SocketChannel/PeerReadsAfterAsyncClose.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@
5050

5151
class PeerReadsAfterAsyncClose {
5252

53-
static Stream<ThreadFactory> factories() {
54-
return Stream.of(Thread.ofPlatform().factory(), Thread.ofVirtual().factory());
55-
}
56-
5753
/**
5854
* Close SocketChannel while a thread is blocked reading from the channel's socket.
5955
*/
60-
@ParameterizedTest
61-
@MethodSource("factories")
62-
void testCloseDuringSocketChannelRead(ThreadFactory factory) throws Exception {
56+
void testCloseDuringSocketChannelRead() throws Exception {
6357
var loopback = InetAddress.getLoopbackAddress();
6458
try (var listener = new ServerSocket()) {
6559
listener.bind(new InetSocketAddress(loopback, 0));
@@ -69,7 +63,7 @@ void testCloseDuringSocketChannelRead(ThreadFactory factory) throws Exception {
6963

7064
// start thread to read from channel
7165
var cceThrown = new AtomicBoolean();
72-
Thread thread = factory.newThread(() -> {
66+
Thread thread = new Thread(() -> {
7367
try {
7468
sc.read(ByteBuffer.allocate(1));
7569
fail();
@@ -102,22 +96,18 @@ void testCloseDuringSocketChannelRead(ThreadFactory factory) throws Exception {
10296
/**
10397
* Close Socket while a thread is blocked reading from the socket.
10498
*/
105-
@ParameterizedTest
106-
@MethodSource("factories")
107-
void testCloseDuringSocketUntimedRead(ThreadFactory factory) throws Exception {
108-
testCloseDuringSocketRead(factory, 0);
99+
void testCloseDuringSocketUntimedRead() throws Exception {
100+
testCloseDuringSocketRead(0);
109101
}
110102

111103
/**
112104
* Close Socket while a thread is blocked reading from the socket with a timeout.
113105
*/
114-
@ParameterizedTest
115-
@MethodSource("factories")
116-
void testCloseDuringSockeTimedRead(ThreadFactory factory) throws Exception {
117-
testCloseDuringSocketRead(factory, 60_000);
106+
void testCloseDuringSockeTimedRead() throws Exception {
107+
testCloseDuringSocketRead(60_000);
118108
}
119109

120-
private void testCloseDuringSocketRead(ThreadFactory factory, int timeout) throws Exception {
110+
private void testCloseDuringSocketRead(int timeout) throws Exception {
121111
var loopback = InetAddress.getLoopbackAddress();
122112
try (var listener = new ServerSocket()) {
123113
listener.bind(new InetSocketAddress(loopback, 0));
@@ -127,7 +117,7 @@ private void testCloseDuringSocketRead(ThreadFactory factory, int timeout) throw
127117

128118
// start thread to read from socket
129119
var seThrown = new AtomicBoolean();
130-
Thread thread = factory.newThread(() -> {
120+
Thread thread = new Thread(() -> {
131121
try {
132122
s.setSoTimeout(timeout);
133123
s.getInputStream().read();
@@ -167,7 +157,7 @@ private void onReach(Thread target, String location, Runnable action) {
167157
int index = location.lastIndexOf('.');
168158
String className = location.substring(0, index);
169159
String methodName = location.substring(index + 1);
170-
Thread.ofPlatform().daemon(true).start(() -> {
160+
new Thread(() -> {
171161
try {
172162
boolean found = false;
173163
while (!found) {
@@ -180,7 +170,7 @@ private void onReach(Thread target, String location, Runnable action) {
180170
} catch (Exception e) {
181171
e.printStackTrace();
182172
}
183-
});
173+
}).start();
184174
}
185175

186176
/**

0 commit comments

Comments
 (0)