Skip to content

Commit 67faaf1

Browse files
Hari Prasad KummariPaul Hohensee
authored andcommitted
8360981: Remove use of Thread.stop in test/jdk/java/net/Socket/DeadlockTest.java
Backport-of: 3263361a28c7e8c02734cb94bc9576e9f3ba5b50
1 parent 56a40f3 commit 67faaf1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/jdk/java/net/Socket/DeadlockTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,19 @@
3131
* @run main/othervm -Djava.net.preferIPv4Stack=true DeadlockTest
3232
*/
3333

34-
import java.net.*;
35-
import java.io.*;
34+
import java.io.IOException;
35+
import java.io.ObjectInputStream;
36+
import java.io.ObjectOutput;
37+
import java.io.ObjectOutputStream;
38+
import java.net.InetAddress;
39+
import java.net.InetSocketAddress;
40+
import java.net.ServerSocket;
41+
import java.net.Socket;
42+
3643
import jdk.test.lib.net.IPSupport;
3744

3845
public class DeadlockTest {
39-
public static void main(String [] argv) throws Exception {
46+
public static void main(String[] argv) throws Exception {
4047
IPSupport.throwSkippedExceptionIfNonOperational();
4148

4249
ServerSocket ss = new ServerSocket(0, 0, InetAddress.getLoopbackAddress());
@@ -52,16 +59,9 @@ public static void main(String [] argv) throws Exception {
5259
Thread c1 = new Thread(ct);
5360
c1.start();
5461

55-
// Wait for the client thread to finish
56-
c1.join(20000);
57-
58-
// If timeout, we assume there is a deadlock
59-
if (c1.isAlive() == true) {
60-
// Close the socket to force the server thread
61-
// terminate too
62-
s1.stop();
63-
throw new Exception("Takes too long. Dead lock");
64-
}
62+
// Wait for the client thread to finish.
63+
// If it doesn't finish then it's a sign of a deadlock
64+
c1.join();
6565
} finally {
6666
ss.close();
6767
clientSocket.close();
@@ -73,7 +73,7 @@ class ServerThread implements Runnable {
7373

7474
private static boolean dbg = false;
7575

76-
ObjectInputStream in;
76+
ObjectInputStream in;
7777
ObjectOutputStream out;
7878

7979
ServerSocket server;

0 commit comments

Comments
 (0)