author | katleman |
Thu, 17 Apr 2014 10:13:36 -0700 | |
changeset 23942 | 7b722b4cdd2d |
parent 13814 | 76b94c403066 |
child 36643 | 6e0a015cd8c8 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
2 |
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* @test |
|
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
25 |
* @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919 |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
26 |
* @run main/othervm AsyncCloseAndInterrupt |
2 | 27 |
* @summary Comprehensive test of asynchronous closing and interruption |
28 |
* @author Mark Reinhold |
|
29 |
*/ |
|
30 |
||
31 |
import java.io.*; |
|
32 |
import java.net.*; |
|
33 |
import java.nio.channels.*; |
|
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
34 |
import java.nio.ByteBuffer; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
35 |
import java.util.ArrayList; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
36 |
import java.util.List; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
37 |
import java.util.concurrent.ExecutorService; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
38 |
import java.util.concurrent.Executors; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
39 |
import java.util.concurrent.ThreadFactory; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
40 |
import java.util.concurrent.Callable; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
41 |
import java.util.concurrent.Future; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
42 |
import java.util.concurrent.TimeUnit; |
2 | 43 |
|
44 |
public class AsyncCloseAndInterrupt { |
|
45 |
||
46 |
static PrintStream log = System.err; |
|
47 |
||
48 |
static void sleep(int ms) { |
|
49 |
try { |
|
50 |
Thread.sleep(ms); |
|
51 |
} catch (InterruptedException x) { } |
|
52 |
} |
|
53 |
||
54 |
// Wildcard address localized to this machine -- Windoze doesn't allow |
|
55 |
// connecting to a server socket that was previously bound to a true |
|
56 |
// wildcard, namely new InetSocketAddress((InetAddress)null, 0). |
|
57 |
// |
|
58 |
private static InetSocketAddress wildcardAddress; |
|
59 |
||
60 |
||
61 |
// Server socket that blindly accepts all connections |
|
62 |
||
63 |
static ServerSocketChannel acceptor; |
|
64 |
||
65 |
private static void initAcceptor() throws IOException { |
|
66 |
acceptor = ServerSocketChannel.open(); |
|
67 |
acceptor.socket().bind(wildcardAddress); |
|
68 |
||
69 |
Thread th = new Thread("Acceptor") { |
|
70 |
public void run() { |
|
71 |
try { |
|
72 |
for (;;) { |
|
73 |
SocketChannel sc = acceptor.accept(); |
|
74 |
} |
|
75 |
} catch (IOException x) { |
|
76 |
x.printStackTrace(); |
|
77 |
} |
|
78 |
} |
|
79 |
}; |
|
80 |
||
81 |
th.setDaemon(true); |
|
82 |
th.start(); |
|
83 |
} |
|
84 |
||
85 |
||
86 |
// Server socket that refuses all connections |
|
87 |
||
88 |
static ServerSocketChannel refuser; |
|
89 |
||
90 |
private static void initRefuser() throws IOException { |
|
91 |
refuser = ServerSocketChannel.open(); |
|
92 |
refuser.socket().bind(wildcardAddress); |
|
93 |
} |
|
94 |
||
95 |
// Dead pipe source and sink |
|
96 |
||
97 |
static Pipe.SourceChannel deadSource; |
|
98 |
static Pipe.SinkChannel deadSink; |
|
99 |
||
100 |
private static void initPipes() throws IOException { |
|
101 |
if (deadSource != null) |
|
102 |
deadSource.close(); |
|
103 |
deadSource = Pipe.open().source(); |
|
104 |
if (deadSink != null) |
|
105 |
deadSink.close(); |
|
106 |
deadSink = Pipe.open().sink(); |
|
107 |
} |
|
108 |
||
109 |
||
110 |
// Files |
|
111 |
||
112 |
private static File fifoFile = null; // File that blocks on reads and writes |
|
113 |
private static File diskFile = null; // Disk file |
|
114 |
||
115 |
private static void initFile() throws Exception { |
|
116 |
||
117 |
diskFile = File.createTempFile("aci", ".tmp"); |
|
118 |
diskFile.deleteOnExit(); |
|
119 |
FileChannel fc = new FileOutputStream(diskFile).getChannel(); |
|
120 |
buffer.clear(); |
|
121 |
if (fc.write(buffer) != buffer.capacity()) |
|
122 |
throw new RuntimeException("Cannot create disk file"); |
|
123 |
fc.close(); |
|
124 |
||
125 |
if (TestUtil.onWindows()) { |
|
126 |
log.println("WARNING: Cannot completely test FileChannels on Windows"); |
|
127 |
return; |
|
128 |
} |
|
129 |
fifoFile = new File("x.fifo"); |
|
130 |
if (fifoFile.exists()) { |
|
131 |
if (!fifoFile.delete()) |
|
132 |
throw new IOException("Cannot delete existing fifo " + fifoFile); |
|
133 |
} |
|
134 |
Process p = Runtime.getRuntime().exec("mkfifo " + fifoFile); |
|
135 |
if (p.waitFor() != 0) |
|
136 |
throw new IOException("Error creating fifo"); |
|
137 |
new RandomAccessFile(fifoFile, "rw").close(); |
|
138 |
||
139 |
} |
|
140 |
||
141 |
||
142 |
// Channel factories |
|
143 |
||
144 |
static abstract class ChannelFactory { |
|
145 |
private final String name; |
|
146 |
ChannelFactory(String name) { |
|
147 |
this.name = name; |
|
148 |
} |
|
149 |
public String toString() { |
|
150 |
return name; |
|
151 |
} |
|
152 |
abstract InterruptibleChannel create() throws IOException; |
|
153 |
} |
|
154 |
||
155 |
static ChannelFactory socketChannelFactory |
|
156 |
= new ChannelFactory("SocketChannel") { |
|
157 |
InterruptibleChannel create() throws IOException { |
|
158 |
return SocketChannel.open(); |
|
159 |
} |
|
160 |
}; |
|
161 |
||
162 |
static ChannelFactory connectedSocketChannelFactory |
|
163 |
= new ChannelFactory("SocketChannel") { |
|
164 |
InterruptibleChannel create() throws IOException { |
|
165 |
SocketAddress sa = acceptor.socket().getLocalSocketAddress(); |
|
166 |
return SocketChannel.open(sa); |
|
167 |
} |
|
168 |
}; |
|
169 |
||
170 |
static ChannelFactory serverSocketChannelFactory |
|
171 |
= new ChannelFactory("ServerSocketChannel") { |
|
172 |
InterruptibleChannel create() throws IOException { |
|
173 |
ServerSocketChannel ssc = ServerSocketChannel.open(); |
|
174 |
ssc.socket().bind(wildcardAddress); |
|
175 |
return ssc; |
|
176 |
} |
|
177 |
}; |
|
178 |
||
179 |
static ChannelFactory datagramChannelFactory |
|
180 |
= new ChannelFactory("DatagramChannel") { |
|
181 |
InterruptibleChannel create() throws IOException { |
|
182 |
DatagramChannel dc = DatagramChannel.open(); |
|
5804
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
183 |
InetAddress lb = InetAddress.getByName("127.0.0.1"); |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
184 |
dc.bind(new InetSocketAddress(lb, 0)); |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
185 |
dc.connect(new InetSocketAddress(lb, 80)); |
2 | 186 |
return dc; |
187 |
} |
|
188 |
}; |
|
189 |
||
190 |
static ChannelFactory pipeSourceChannelFactory |
|
191 |
= new ChannelFactory("Pipe.SourceChannel") { |
|
192 |
InterruptibleChannel create() throws IOException { |
|
193 |
// ## arrange to close sink |
|
194 |
return Pipe.open().source(); |
|
195 |
} |
|
196 |
}; |
|
197 |
||
198 |
static ChannelFactory pipeSinkChannelFactory |
|
199 |
= new ChannelFactory("Pipe.SinkChannel") { |
|
200 |
InterruptibleChannel create() throws IOException { |
|
201 |
// ## arrange to close source |
|
202 |
return Pipe.open().sink(); |
|
203 |
} |
|
204 |
}; |
|
205 |
||
206 |
static ChannelFactory fifoFileChannelFactory |
|
207 |
= new ChannelFactory("FileChannel") { |
|
208 |
InterruptibleChannel create() throws IOException { |
|
209 |
return new RandomAccessFile(fifoFile, "rw").getChannel(); |
|
210 |
} |
|
211 |
}; |
|
212 |
||
213 |
static ChannelFactory diskFileChannelFactory |
|
214 |
= new ChannelFactory("FileChannel") { |
|
215 |
InterruptibleChannel create() throws IOException { |
|
216 |
return new RandomAccessFile(diskFile, "rw").getChannel(); |
|
217 |
} |
|
218 |
}; |
|
219 |
||
220 |
||
221 |
// I/O operations |
|
222 |
||
223 |
static abstract class Op { |
|
224 |
private final String name; |
|
225 |
protected Op(String name) { |
|
226 |
this.name = name; |
|
227 |
} |
|
228 |
abstract void doIO(InterruptibleChannel ich) throws IOException; |
|
229 |
void setup() throws IOException { } |
|
230 |
public String toString() { return name; } |
|
231 |
} |
|
232 |
||
233 |
static ByteBuffer buffer = ByteBuffer.allocateDirect(1 << 20); |
|
234 |
||
235 |
static ByteBuffer[] buffers = new ByteBuffer[] { |
|
236 |
ByteBuffer.allocateDirect(1 << 19), |
|
237 |
ByteBuffer.allocateDirect(1 << 19) |
|
238 |
}; |
|
239 |
||
240 |
static void clearBuffers() { |
|
241 |
buffers[0].clear(); |
|
242 |
buffers[1].clear(); |
|
243 |
} |
|
244 |
||
245 |
static void show(Channel ch) { |
|
246 |
log.print("Channel " + (ch.isOpen() ? "open" : "closed")); |
|
247 |
if (ch.isOpen() && (ch instanceof SocketChannel)) { |
|
248 |
SocketChannel sc = (SocketChannel)ch; |
|
249 |
if (sc.socket().isInputShutdown()) |
|
250 |
log.print(", input shutdown"); |
|
251 |
if (sc.socket().isOutputShutdown()) |
|
252 |
log.print(", output shutdown"); |
|
253 |
} |
|
254 |
log.println(); |
|
255 |
} |
|
256 |
||
257 |
static final Op READ = new Op("read") { |
|
258 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
259 |
ReadableByteChannel rbc = (ReadableByteChannel)ich; |
|
260 |
buffer.clear(); |
|
261 |
int n = rbc.read(buffer); |
|
262 |
log.println("Read returned " + n); |
|
263 |
show(rbc); |
|
264 |
if (rbc.isOpen() |
|
265 |
&& (n == -1) |
|
266 |
&& (rbc instanceof SocketChannel) |
|
267 |
&& ((SocketChannel)rbc).socket().isInputShutdown()) { |
|
268 |
return; |
|
269 |
} |
|
270 |
throw new RuntimeException("Read succeeded"); |
|
271 |
} |
|
272 |
}; |
|
273 |
||
274 |
static final Op READV = new Op("readv") { |
|
275 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
276 |
ScatteringByteChannel sbc = (ScatteringByteChannel)ich; |
|
277 |
clearBuffers(); |
|
278 |
int n = (int)sbc.read(buffers); |
|
279 |
log.println("Read returned " + n); |
|
280 |
show(sbc); |
|
281 |
if (sbc.isOpen() |
|
282 |
&& (n == -1) |
|
283 |
&& (sbc instanceof SocketChannel) |
|
284 |
&& ((SocketChannel)sbc).socket().isInputShutdown()) { |
|
285 |
return; |
|
286 |
} |
|
287 |
throw new RuntimeException("Read succeeded"); |
|
288 |
} |
|
289 |
}; |
|
290 |
||
291 |
static final Op RECEIVE = new Op("receive") { |
|
292 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
293 |
DatagramChannel dc = (DatagramChannel)ich; |
|
294 |
buffer.clear(); |
|
295 |
dc.receive(buffer); |
|
296 |
show(dc); |
|
297 |
throw new RuntimeException("Read succeeded"); |
|
298 |
} |
|
299 |
}; |
|
300 |
||
301 |
static final Op WRITE = new Op("write") { |
|
302 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
303 |
||
304 |
WritableByteChannel wbc = (WritableByteChannel)ich; |
|
305 |
||
306 |
SocketChannel sc = null; |
|
307 |
if (wbc instanceof SocketChannel) |
|
308 |
sc = (SocketChannel)wbc; |
|
309 |
||
310 |
int n = 0; |
|
311 |
for (;;) { |
|
312 |
buffer.clear(); |
|
313 |
int d = wbc.write(buffer); |
|
314 |
n += d; |
|
315 |
if (!wbc.isOpen()) |
|
316 |
break; |
|
317 |
if ((sc != null) && sc.socket().isOutputShutdown()) |
|
318 |
break; |
|
319 |
} |
|
320 |
log.println("Wrote " + n + " bytes"); |
|
321 |
show(wbc); |
|
322 |
} |
|
323 |
}; |
|
324 |
||
325 |
static final Op WRITEV = new Op("writev") { |
|
326 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
327 |
||
328 |
GatheringByteChannel gbc = (GatheringByteChannel)ich; |
|
329 |
||
330 |
SocketChannel sc = null; |
|
331 |
if (gbc instanceof SocketChannel) |
|
332 |
sc = (SocketChannel)gbc; |
|
333 |
||
334 |
int n = 0; |
|
335 |
for (;;) { |
|
336 |
clearBuffers(); |
|
337 |
int d = (int)gbc.write(buffers); |
|
338 |
n += d; |
|
339 |
if (!gbc.isOpen()) |
|
340 |
break; |
|
341 |
if ((sc != null) && sc.socket().isOutputShutdown()) |
|
342 |
break; |
|
343 |
} |
|
344 |
log.println("Wrote " + n + " bytes"); |
|
345 |
show(gbc); |
|
346 |
||
347 |
} |
|
348 |
}; |
|
349 |
||
350 |
static final Op CONNECT = new Op("connect") { |
|
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
351 |
void setup() { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
352 |
waitPump("connect wait for pumping refuser ..."); |
2 | 353 |
} |
354 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
355 |
SocketChannel sc = (SocketChannel)ich; |
|
356 |
if (sc.connect(refuser.socket().getLocalSocketAddress())) |
|
357 |
throw new RuntimeException("Connection succeeded"); |
|
358 |
throw new RuntimeException("Connection did not block"); |
|
359 |
} |
|
360 |
}; |
|
361 |
||
362 |
static final Op FINISH_CONNECT = new Op("finishConnect") { |
|
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
363 |
void setup() { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
364 |
waitPump("finishConnect wait for pumping refuser ..."); |
2 | 365 |
} |
366 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
367 |
SocketChannel sc = (SocketChannel)ich; |
|
368 |
sc.configureBlocking(false); |
|
369 |
SocketAddress sa = refuser.socket().getLocalSocketAddress(); |
|
370 |
if (sc.connect(sa)) |
|
371 |
throw new RuntimeException("Connection succeeded"); |
|
372 |
sc.configureBlocking(true); |
|
373 |
if (sc.finishConnect()) |
|
374 |
throw new RuntimeException("Connection succeeded"); |
|
375 |
throw new RuntimeException("Connection did not block"); |
|
376 |
} |
|
377 |
}; |
|
378 |
||
379 |
static final Op ACCEPT = new Op("accept") { |
|
380 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
381 |
ServerSocketChannel ssc = (ServerSocketChannel)ich; |
|
382 |
ssc.accept(); |
|
383 |
throw new RuntimeException("Accept succeeded"); |
|
384 |
} |
|
385 |
}; |
|
386 |
||
387 |
// Use only with diskFileChannelFactory |
|
388 |
static final Op TRANSFER_TO = new Op("transferTo") { |
|
389 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
390 |
FileChannel fc = (FileChannel)ich; |
|
391 |
long n = fc.transferTo(0, fc.size(), deadSink); |
|
392 |
log.println("Transferred " + n + " bytes"); |
|
393 |
show(fc); |
|
394 |
} |
|
395 |
}; |
|
396 |
||
397 |
// Use only with diskFileChannelFactory |
|
398 |
static final Op TRANSFER_FROM = new Op("transferFrom") { |
|
399 |
void doIO(InterruptibleChannel ich) throws IOException { |
|
400 |
FileChannel fc = (FileChannel)ich; |
|
401 |
long n = fc.transferFrom(deadSource, 0, 1 << 20); |
|
402 |
log.println("Transferred " + n + " bytes"); |
|
403 |
show(fc); |
|
404 |
} |
|
405 |
}; |
|
406 |
||
407 |
||
408 |
||
409 |
// Test modes |
|
410 |
||
411 |
static final int TEST_PREINTR = 0; // Interrupt thread before I/O |
|
412 |
static final int TEST_INTR = 1; // Interrupt thread during I/O |
|
413 |
static final int TEST_CLOSE = 2; // Close channel during I/O |
|
414 |
static final int TEST_SHUTI = 3; // Shutdown input during I/O |
|
415 |
static final int TEST_SHUTO = 4; // Shutdown output during I/O |
|
416 |
||
417 |
static final String[] testName = new String[] { |
|
418 |
"pre-interrupt", "interrupt", "close", |
|
419 |
"shutdown-input", "shutdown-output" |
|
420 |
}; |
|
421 |
||
422 |
||
423 |
static class Tester extends TestThread { |
|
424 |
||
425 |
private InterruptibleChannel ch; |
|
426 |
private Op op; |
|
427 |
private int test; |
|
428 |
volatile boolean ready = false; |
|
429 |
||
430 |
protected Tester(ChannelFactory cf, InterruptibleChannel ch, |
|
431 |
Op op, int test) |
|
432 |
{ |
|
433 |
super(cf + "/" + op + "/" + testName[test]); |
|
434 |
this.ch = ch; |
|
435 |
this.op = op; |
|
436 |
this.test = test; |
|
437 |
} |
|
438 |
||
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
439 |
@SuppressWarnings("fallthrough") |
2 | 440 |
private void caught(Channel ch, IOException x) { |
441 |
String xn = x.getClass().getName(); |
|
442 |
switch (test) { |
|
443 |
||
444 |
case TEST_PREINTR: |
|
445 |
case TEST_INTR: |
|
446 |
if (!xn.equals("java.nio.channels.ClosedByInterruptException")) |
|
447 |
throw new RuntimeException("Wrong exception thrown: " + x); |
|
448 |
break; |
|
449 |
||
450 |
case TEST_CLOSE: |
|
451 |
case TEST_SHUTO: |
|
452 |
if (!xn.equals("java.nio.channels.AsynchronousCloseException")) |
|
453 |
throw new RuntimeException("Wrong exception thrown: " + x); |
|
454 |
break; |
|
455 |
||
456 |
case TEST_SHUTI: |
|
457 |
if (TestUtil.onWindows()) |
|
458 |
break; |
|
459 |
// FALL THROUGH |
|
460 |
||
461 |
default: |
|
462 |
throw new Error(x); |
|
463 |
} |
|
464 |
||
465 |
if (ch.isOpen()) { |
|
466 |
if (test == TEST_SHUTO) { |
|
467 |
SocketChannel sc = (SocketChannel)ch; |
|
468 |
if (!sc.socket().isOutputShutdown()) |
|
469 |
throw new RuntimeException("Output not shutdown"); |
|
470 |
} else if ((test == TEST_INTR) && (op == TRANSFER_FROM)) { |
|
471 |
// Let this case pass -- CBIE applies to other channel |
|
472 |
} else { |
|
473 |
throw new RuntimeException("Channel still open"); |
|
474 |
} |
|
475 |
} |
|
476 |
||
477 |
log.println("Thrown as expected: " + x); |
|
478 |
} |
|
479 |
||
480 |
final void go() throws Exception { |
|
481 |
if (test == TEST_PREINTR) |
|
482 |
Thread.currentThread().interrupt(); |
|
483 |
ready = true; |
|
484 |
try { |
|
485 |
op.doIO(ch); |
|
486 |
} catch (ClosedByInterruptException x) { |
|
487 |
caught(ch, x); |
|
488 |
} catch (AsynchronousCloseException x) { |
|
489 |
caught(ch, x); |
|
490 |
} finally { |
|
491 |
ch.close(); |
|
492 |
} |
|
493 |
} |
|
494 |
||
495 |
} |
|
496 |
||
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
497 |
private static volatile boolean pumpDone = false; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
498 |
private static volatile boolean pumpReady = false; |
2 | 499 |
|
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
500 |
private static void waitPump(String msg){ |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
501 |
pumpReady = false; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
502 |
log.println(msg); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
503 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
504 |
while (!pumpReady){ |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
505 |
sleep(200); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
506 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
507 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
508 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
509 |
// Create a pump thread dedicated to saturate refuser's connection backlog |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
510 |
private static Future<Integer> pumpRefuser(ExecutorService pumperExecutor) { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
511 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
512 |
Callable<Integer> pumpTask = new Callable<Integer>() { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
513 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
514 |
@Override |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
515 |
public Integer call() throws IOException { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
516 |
// Can't reliably saturate connection backlog on Windows Server editions |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
517 |
assert !TestUtil.onWindows(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
518 |
log.println("Start pumping refuser ..."); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
519 |
List<SocketChannel> refuserClients = new ArrayList<>(); |
2 | 520 |
|
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
521 |
// Saturate the refuser's connection backlog so that further connection |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
522 |
// attempts will be blocked |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
523 |
while (!pumpDone) { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
524 |
SocketChannel sc = SocketChannel.open(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
525 |
sc.configureBlocking(false); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
526 |
boolean connected = sc.connect(refuser.socket().getLocalSocketAddress()); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
527 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
528 |
// Assume that the connection backlog is saturated if a |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
529 |
// client cannot connect to the refuser within 50 miliseconds |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
530 |
long start = System.currentTimeMillis(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
531 |
while (!connected && (System.currentTimeMillis() - start < 50)) { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
532 |
connected = sc.finishConnect(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
533 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
534 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
535 |
if (connected) { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
536 |
// Retain so that finalizer doesn't close |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
537 |
refuserClients.add(sc); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
538 |
pumpReady = false; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
539 |
} else { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
540 |
sc.close(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
541 |
pumpReady = true; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
542 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
543 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
544 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
545 |
log.println("Stop pumping refuser ..."); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
546 |
return refuserClients.size(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
547 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
548 |
}; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
549 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
550 |
return pumperExecutor.submit(pumpTask); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
551 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
552 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
553 |
// Test |
2 | 554 |
static void test(ChannelFactory cf, Op op, int test) |
555 |
throws Exception |
|
556 |
{ |
|
557 |
log.println(); |
|
558 |
initPipes(); |
|
559 |
InterruptibleChannel ch = cf.create(); |
|
560 |
Tester t = new Tester(cf, ch, op, test); |
|
561 |
log.println(t); |
|
562 |
op.setup(); |
|
563 |
t.start(); |
|
564 |
do { |
|
565 |
sleep(50); |
|
566 |
} while (!t.ready); |
|
567 |
||
568 |
sleep(100); |
|
569 |
||
570 |
switch (test) { |
|
571 |
||
572 |
case TEST_INTR: |
|
573 |
t.interrupt(); |
|
574 |
break; |
|
575 |
||
576 |
case TEST_CLOSE: |
|
577 |
ch.close(); |
|
578 |
break; |
|
579 |
||
580 |
case TEST_SHUTI: |
|
581 |
if (TestUtil.onWindows()) { |
|
582 |
log.println("WARNING: Asynchronous shutdown not working on Windows"); |
|
583 |
ch.close(); |
|
584 |
} else { |
|
585 |
((SocketChannel)ch).socket().shutdownInput(); |
|
586 |
} |
|
587 |
break; |
|
588 |
||
589 |
case TEST_SHUTO: |
|
590 |
if (TestUtil.onWindows()) { |
|
591 |
log.println("WARNING: Asynchronous shutdown not working on Windows"); |
|
592 |
ch.close(); |
|
593 |
} else { |
|
594 |
((SocketChannel)ch).socket().shutdownOutput(); |
|
595 |
} |
|
596 |
break; |
|
597 |
||
598 |
default: |
|
599 |
break; |
|
600 |
} |
|
601 |
||
602 |
t.finishAndThrow(500); |
|
603 |
} |
|
604 |
||
605 |
||
606 |
static void test(ChannelFactory cf, Op op) throws Exception { |
|
607 |
// Test INTR cases before PREINTER cases since sometimes |
|
608 |
// interrupted threads can't load classes |
|
609 |
test(cf, op, TEST_INTR); |
|
610 |
test(cf, op, TEST_PREINTR); |
|
611 |
||
612 |
// Bugs, see FileChannelImpl for details |
|
613 |
if (op == TRANSFER_FROM) { |
|
614 |
log.println("WARNING: transferFrom/close not tested"); |
|
615 |
return; |
|
616 |
} |
|
694
0da2a4a73721
6710579: (ch) test/java/nio/channels/AsyncCloseAndInterrupt fails (lnx)
alanb
parents:
693
diff
changeset
|
617 |
if ((op == TRANSFER_TO) && !TestUtil.onWindows()) { |
2 | 618 |
log.println("WARNING: transferTo/close not tested"); |
619 |
return; |
|
620 |
} |
|
621 |
||
622 |
test(cf, op, TEST_CLOSE); |
|
623 |
} |
|
624 |
||
625 |
static void test(ChannelFactory cf) |
|
626 |
throws Exception |
|
627 |
{ |
|
628 |
InterruptibleChannel ch = cf.create(); // Sample channel |
|
629 |
ch.close(); |
|
630 |
||
631 |
if (ch instanceof ReadableByteChannel) { |
|
632 |
test(cf, READ); |
|
633 |
if (ch instanceof SocketChannel) |
|
634 |
test(cf, READ, TEST_SHUTI); |
|
635 |
} |
|
636 |
||
637 |
if (ch instanceof ScatteringByteChannel) { |
|
638 |
test(cf, READV); |
|
639 |
if (ch instanceof SocketChannel) |
|
640 |
test(cf, READV, TEST_SHUTI); |
|
641 |
} |
|
642 |
||
643 |
if (ch instanceof DatagramChannel) { |
|
644 |
test(cf, RECEIVE); |
|
645 |
||
646 |
// Return here: We can't effectively test writes since, if they |
|
647 |
// block, they do so only for a fleeting moment unless the network |
|
648 |
// interface is overloaded. |
|
649 |
return; |
|
650 |
||
651 |
} |
|
652 |
||
653 |
if (ch instanceof WritableByteChannel) { |
|
654 |
test(cf, WRITE); |
|
655 |
if (ch instanceof SocketChannel) |
|
656 |
test(cf, WRITE, TEST_SHUTO); |
|
657 |
} |
|
658 |
||
659 |
if (ch instanceof GatheringByteChannel) { |
|
660 |
test(cf, WRITEV); |
|
661 |
if (ch instanceof SocketChannel) |
|
662 |
test(cf, WRITEV, TEST_SHUTO); |
|
663 |
} |
|
664 |
||
665 |
} |
|
666 |
||
667 |
public static void main(String[] args) throws Exception { |
|
668 |
||
669 |
wildcardAddress = new InetSocketAddress(InetAddress.getLocalHost(), 0); |
|
670 |
initAcceptor(); |
|
5804
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
671 |
if (!TestUtil.onWindows()) |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
672 |
initRefuser(); |
2 | 673 |
initPipes(); |
674 |
initFile(); |
|
675 |
||
13028
f72c7e618ed0
7177617: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing (win)
alanb
parents:
7668
diff
changeset
|
676 |
if (TestUtil.onWindows()) { |
2 | 677 |
log.println("WARNING: Cannot test FileChannel transfer operations" |
13028
f72c7e618ed0
7177617: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing (win)
alanb
parents:
7668
diff
changeset
|
678 |
+ " on Windows"); |
2 | 679 |
} else { |
680 |
test(diskFileChannelFactory, TRANSFER_TO); |
|
681 |
test(diskFileChannelFactory, TRANSFER_FROM); |
|
682 |
} |
|
683 |
if (fifoFile != null) |
|
684 |
test(fifoFileChannelFactory); |
|
685 |
||
686 |
// Testing positional file reads and writes is impractical: It requires |
|
687 |
// access to a large file soft-mounted via NFS, and even then isn't |
|
688 |
// completely guaranteed to work. |
|
689 |
// |
|
690 |
// Testing map is impractical and arguably unnecessary: It's |
|
691 |
// unclear under what conditions mmap(2) will actually block. |
|
692 |
||
693 |
test(connectedSocketChannelFactory); |
|
5804
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
694 |
|
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
695 |
if (TestUtil.onWindows()) { |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
696 |
log.println("WARNING Cannot reliably test connect/finishConnect" |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
697 |
+ " operations on Windows"); |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
698 |
} else { |
13814
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
699 |
// Only the following tests need refuser's connection backlog |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
700 |
// to be saturated |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
701 |
ExecutorService pumperExecutor = |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
702 |
Executors.newSingleThreadExecutor( |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
703 |
new ThreadFactory() { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
704 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
705 |
@Override |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
706 |
public Thread newThread(Runnable r) { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
707 |
Thread t = new Thread(r); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
708 |
t.setDaemon(true); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
709 |
t.setName("Pumper"); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
710 |
return t; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
711 |
} |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
712 |
}); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
713 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
714 |
pumpDone = false; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
715 |
try { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
716 |
Future<Integer> pumpFuture = pumpRefuser(pumperExecutor); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
717 |
waitPump("\nWait for initial Pump"); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
718 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
719 |
test(socketChannelFactory, CONNECT); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
720 |
test(socketChannelFactory, FINISH_CONNECT); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
721 |
|
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
722 |
pumpDone = true; |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
723 |
Integer newConn = pumpFuture.get(30, TimeUnit.SECONDS); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
724 |
log.println("Pump " + newConn + " connections."); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
725 |
} finally { |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
726 |
pumperExecutor.shutdown(); |
76b94c403066
7142919: TEST_BUG: java/nio/channels/AsyncCloseAndInterrupt.java failing intermittently [sol11]
dxu
parents:
13028
diff
changeset
|
727 |
} |
5804
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
728 |
} |
faf9bd47d6ce
6395224: (so) SocketChannel writer blocked on large buffer is not preempted by close method (vista)
alanb
parents:
5506
diff
changeset
|
729 |
|
2 | 730 |
test(serverSocketChannelFactory, ACCEPT); |
731 |
test(datagramChannelFactory); |
|
732 |
test(pipeSourceChannelFactory); |
|
733 |
test(pipeSinkChannelFactory); |
|
734 |
} |
|
735 |
} |