mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
690ba9cdc7
This was a bug, wherein upon throwing an exception, we would try to allocate memory for the message - all while holding a critical reference to the jbyteArray representing the exception string. This caused an expect to fail in allocate3.
34 lines
918 B
Java
34 lines
918 B
Java
import java.net.SocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.nio.channels.SocketChannel;
|
|
import java.io.IOException;
|
|
|
|
public class Sockets {
|
|
private static void expect(boolean v) {
|
|
if (! v) throw new RuntimeException();
|
|
}
|
|
|
|
public static void testFailedBind() throws Exception {
|
|
final String Hostname = "localhost";
|
|
final int Port = 22046; // hopefully this port is unused
|
|
final SocketAddress Address = new InetSocketAddress(Hostname, Port);
|
|
final byte[] Message = "hello, world!".getBytes();
|
|
|
|
SocketChannel out = SocketChannel.open();
|
|
try {
|
|
try {
|
|
out.connect(Address);
|
|
expect(false);
|
|
} catch(IOException e) {
|
|
// We're good. This previously triggered a vm assert, rather than an exception
|
|
}
|
|
} finally {
|
|
out.close();
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
testFailedBind();
|
|
}
|
|
}
|