6934585: TEST_BUG: java/nio/channels/AsynchronousSocketChannel/Basic.java
Reviewed-by: chegar
This commit is contained in:
parent
b0277a9631
commit
82adf1a224
@ -737,9 +737,6 @@ sun/net/www/protocol/http/DigestTest.java generic-all
|
|||||||
# Suspect many of these tests auffer from using fixed ports, no concrete
|
# Suspect many of these tests auffer from using fixed ports, no concrete
|
||||||
# evidence.
|
# evidence.
|
||||||
|
|
||||||
# Failing on Solaris x86 and Linux x86, filed 6934585
|
|
||||||
java/nio/channels/AsynchronousSocketChannel/Basic.java generic-all
|
|
||||||
|
|
||||||
# Occasionally Failing with java.lang.AssertionError on Windows X64
|
# Occasionally Failing with java.lang.AssertionError on Windows X64
|
||||||
# at sun.nio.ch.PendingIoCache.clearPendingIoMap(PendingIoCache.java:144)
|
# at sun.nio.ch.PendingIoCache.clearPendingIoMap(PendingIoCache.java:144)
|
||||||
#java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java windows-all
|
#java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java windows-all
|
||||||
@ -767,10 +764,6 @@ java/nio/channels/Selector/SelectWrite.java generic-all
|
|||||||
# Fails on Fedora 9 32bit times out
|
# Fails on Fedora 9 32bit times out
|
||||||
java/nio/channels/DatagramChannel/EmptyBuffer.java generic-all
|
java/nio/channels/DatagramChannel/EmptyBuffer.java generic-all
|
||||||
|
|
||||||
# Fails on Windows 2000, ExceptionInInitializerError
|
|
||||||
# in WindowsAsynchronousServerSocketChannelImpl.java:316
|
|
||||||
java/nio/channels/AsynchronousChannelGroup/Unbounded.java generic-all
|
|
||||||
|
|
||||||
# Fails on Windows 2000, times out
|
# Fails on Windows 2000, times out
|
||||||
java/nio/channels/FileChannel/Transfer.java generic-all
|
java/nio/channels/FileChannel/Transfer.java generic-all
|
||||||
|
|
||||||
@ -812,11 +805,12 @@ java/nio/channels/Selector/HelperSlowToDie.java generic-all
|
|||||||
# Timeouts etc. on Window
|
# Timeouts etc. on Window
|
||||||
java/nio/channels/AsyncCloseAndInterrupt.java windows-all
|
java/nio/channels/AsyncCloseAndInterrupt.java windows-all
|
||||||
|
|
||||||
# Gets java.lang.ExceptionInInitializerError on windows: (Windows 2000 only?)
|
# Gets java.lang.ExceptionInInitializerError on Windows 2000 (need XP or newer)
|
||||||
java/nio/channels/AsynchronousChannelGroup/Basic.java windows-5.0
|
java/nio/channels/AsynchronousChannelGroup/Basic.java windows-5.0
|
||||||
java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java windows-5.0
|
java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java windows-5.0
|
||||||
java/nio/channels/AsynchronousChannelGroup/Identity.java windows-5.0
|
java/nio/channels/AsynchronousChannelGroup/Identity.java windows-5.0
|
||||||
java/nio/channels/AsynchronousChannelGroup/Restart.java windows-5.0
|
java/nio/channels/AsynchronousChannelGroup/Restart.java windows-5.0
|
||||||
|
java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-5.0
|
||||||
java/nio/channels/AsynchronousDatagramChannel/Basic.java windows-5.0
|
java/nio/channels/AsynchronousDatagramChannel/Basic.java windows-5.0
|
||||||
java/nio/channels/AsynchronousFileChannel/Lock.java windows-5.0
|
java/nio/channels/AsynchronousFileChannel/Lock.java windows-5.0
|
||||||
java/nio/channels/AsynchronousServerSocketChannel/Basic.java windows-5.0
|
java/nio/channels/AsynchronousServerSocketChannel/Basic.java windows-5.0
|
||||||
|
@ -196,18 +196,16 @@ public class Basic {
|
|||||||
|
|
||||||
System.out.println("-- connect to non-existent host --");
|
System.out.println("-- connect to non-existent host --");
|
||||||
|
|
||||||
// test failure
|
// test that failure to connect closes the channel
|
||||||
InetAddress badHost = InetAddress.getByName("1.2.3.4");
|
ch = AsynchronousSocketChannel.open();
|
||||||
if (!badHost.isReachable(10*1000)) {
|
try {
|
||||||
|
ch.connect(genSocketAddress()).get();
|
||||||
ch = AsynchronousSocketChannel.open();
|
} catch (ExecutionException x) {
|
||||||
try {
|
// failed to establish connection
|
||||||
ch.connect(new InetSocketAddress(badHost, 9876)).get();
|
|
||||||
throw new RuntimeException("Connection should not be established");
|
|
||||||
} catch (ExecutionException x) {
|
|
||||||
}
|
|
||||||
if (ch.isOpen())
|
if (ch.isOpen())
|
||||||
throw new RuntimeException("Channel should be closed");
|
throw new RuntimeException("Channel should be closed");
|
||||||
|
} finally {
|
||||||
|
ch.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
server.close();
|
server.close();
|
||||||
@ -219,27 +217,22 @@ public class Basic {
|
|||||||
AsynchronousSocketChannel ch;
|
AsynchronousSocketChannel ch;
|
||||||
|
|
||||||
// asynchronous close while connecting
|
// asynchronous close while connecting
|
||||||
InetAddress rh = InetAddress.getByName("1.2.3.4");
|
ch = AsynchronousSocketChannel.open();
|
||||||
if (!rh.isReachable(3000)) {
|
Future<Void> connectResult = ch.connect(genSocketAddress());
|
||||||
InetSocketAddress isa = new InetSocketAddress(rh, 1234);
|
|
||||||
|
|
||||||
ch = AsynchronousSocketChannel.open();
|
// give time to initiate the connect (SYN)
|
||||||
Future<Void> result = ch.connect(isa);
|
Thread.sleep(50);
|
||||||
|
|
||||||
// give time to initiate the connect (SYN)
|
// close
|
||||||
Thread.sleep(50);
|
ch.close();
|
||||||
|
|
||||||
// close
|
// check that exception is thrown in timely manner
|
||||||
ch.close();
|
try {
|
||||||
|
connectResult.get(5, TimeUnit.SECONDS);
|
||||||
// check that AsynchronousCloseException is thrown
|
} catch (TimeoutException x) {
|
||||||
try {
|
throw new RuntimeException("AsynchronousCloseException not thrown");
|
||||||
result.get();
|
} catch (ExecutionException x) {
|
||||||
throw new RuntimeException("Should not connect");
|
// expected
|
||||||
} catch (ExecutionException x) {
|
|
||||||
if (!(x.getCause() instanceof AsynchronousCloseException))
|
|
||||||
throw new RuntimeException(x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("-- asynchronous close when reading --");
|
System.out.println("-- asynchronous close when reading --");
|
||||||
@ -785,30 +778,47 @@ public class Basic {
|
|||||||
ch.close();
|
ch.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns ByteBuffer with random bytes
|
// returns ByteBuffer with random bytes
|
||||||
static ByteBuffer genBuffer() {
|
static ByteBuffer genBuffer() {
|
||||||
int size = 1024 + rand.nextInt(16000);
|
int size = 1024 + rand.nextInt(16000);
|
||||||
byte[] buf = new byte[size];
|
byte[] buf = new byte[size];
|
||||||
rand.nextBytes(buf);
|
rand.nextBytes(buf);
|
||||||
boolean useDirect = rand.nextBoolean();
|
boolean useDirect = rand.nextBoolean();
|
||||||
if (useDirect) {
|
if (useDirect) {
|
||||||
ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
|
ByteBuffer bb = ByteBuffer.allocateDirect(buf.length);
|
||||||
bb.put(buf);
|
bb.put(buf);
|
||||||
bb.flip();
|
bb.flip();
|
||||||
return bb;
|
return bb;
|
||||||
} else {
|
} else {
|
||||||
return ByteBuffer.wrap(buf);
|
return ByteBuffer.wrap(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return ByteBuffer[] with random bytes
|
// return ByteBuffer[] with random bytes
|
||||||
static ByteBuffer[] genBuffers(int max) {
|
static ByteBuffer[] genBuffers(int max) {
|
||||||
int len = 1;
|
int len = 1;
|
||||||
if (max > 1)
|
if (max > 1)
|
||||||
len += rand.nextInt(max);
|
len += rand.nextInt(max);
|
||||||
ByteBuffer[] bufs = new ByteBuffer[len];
|
ByteBuffer[] bufs = new ByteBuffer[len];
|
||||||
for (int i=0; i<len; i++)
|
for (int i=0; i<len; i++)
|
||||||
bufs[i] = genBuffer();
|
bufs[i] = genBuffer();
|
||||||
return bufs;
|
return bufs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return random SocketAddress
|
||||||
|
static SocketAddress genSocketAddress() {
|
||||||
|
StringBuilder sb = new StringBuilder("10.");
|
||||||
|
sb.append(rand.nextInt(256));
|
||||||
|
sb.append('.');
|
||||||
|
sb.append(rand.nextInt(256));
|
||||||
|
sb.append('.');
|
||||||
|
sb.append(rand.nextInt(256));
|
||||||
|
InetAddress rh;
|
||||||
|
try {
|
||||||
|
rh = InetAddress.getByName(sb.toString());
|
||||||
|
} catch (UnknownHostException x) {
|
||||||
|
throw new InternalError("Should not happen");
|
||||||
|
}
|
||||||
|
return new InetSocketAddress(rh, rand.nextInt(65535)+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user