Skip to content

Commit 0cb267a

Browse files
committed
8211325: test/jdk/java/net/Socket/LingerTest.java fails with cleaning up
Reviewed-by: dfuchs
1 parent 9452b88 commit 0cb267a

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ java/net/MulticastSocket/SetGetNetworkInterfaceTest.java 8207404 aix-all
556556

557557
java/net/DatagramSocket/SendDatagramToBadAddress.java 7143960 macosx-all
558558

559-
java/net/Socket/LingerTest.java 8208690 generic-all
560-
561559
############################################################################
562560

563561
# jdk_nio

test/jdk/java/net/Socket/LingerTest.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,38 +109,45 @@ public static void main(String args[]) throws Exception {
109109
Socket s2 = ss.accept();
110110

111111
// setup conditions for untransmitted data and lengthy
112-
// linger interval
113-
s1.setSendBufferSize(128*1024);
112+
// linger interval
113+
s1.setSendBufferSize(128*1024);
114114
s1.setSoLinger(true, 30);
115115
s2.setReceiveBufferSize(1*1024);
116116

117117
// start sender
118-
Thread thr = new Thread(new Sender(s1));
119-
thr.start();
118+
Thread senderThread = new Thread(new Sender(s1));
119+
senderThread.start();
120120

121121
// other thread that will connect after 5 seconds.
122-
Other other = new Other(ss.getLocalPort(), 5000);
123-
thr = new Thread(other);
124-
thr.start();
122+
Other other = new Other(ss.getLocalPort(), 5000);
123+
Thread otherThread = new Thread(other);
124+
otherThread.start();
125125

126126
// give sender time to queue the data
127-
System.out.println ("Main sleep 1000");
128-
Thread.sleep(1000);
129-
System.out.println ("Main continue");
127+
System.out.println ("Main sleep 1000");
128+
Thread.sleep(1000);
129+
System.out.println ("Main continue");
130130

131131
// close the socket asynchronously
132-
(new Thread(new Closer(s1))).start();
132+
Thread closerThread = new Thread(new Closer(s1));
133+
closerThread.start();
133134

134-
System.out.println ("Main sleep 15000");
135+
System.out.println ("Main sleep 15000");
135136
// give other time to run
136-
Thread.sleep(15000);
137-
System.out.println ("Main closing serversocket");
137+
Thread.sleep(15000);
138+
System.out.println ("Main closing serversocket");
138139

139140
ss.close();
140141
// check that other is done
141-
if (!other.connected()) {
142+
if (!other.connected()) {
142143
throw new RuntimeException("Other thread is blocked");
143144
}
145+
146+
// await termination of all test related threads
147+
senderThread.join(60_000);
148+
otherThread.join(60_000);
149+
closerThread.join(60_000);
150+
144151
System.out.println ("Main ends");
145152
}
146153
}

0 commit comments

Comments
 (0)