mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
Merge pull request #246 from joshuawarner32/master
Stop using *Critical functions in throwIOException
This commit is contained in:
commit
172ef9a7e6
@ -115,12 +115,17 @@ throwIOException(JNIEnv* e, const char* s)
|
|||||||
throwNew(e, "java/io/IOException", s);
|
throwNew(e, "java/io/IOException", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void throwIOException(JNIEnv* e, jbyteArray a)
|
||||||
throwIOException(JNIEnv* e, jbyteArray a)
|
|
||||||
{
|
{
|
||||||
jbyte* s = static_cast<jbyte*>(e->GetPrimitiveArrayCritical(a, 0));
|
size_t length = e->GetArrayLength(a);
|
||||||
throwIOException(e, reinterpret_cast<const char*>(s));
|
uint8_t* buf = static_cast<uint8_t*>(allocate(e, length));
|
||||||
e->ReleasePrimitiveArrayCritical(a, s, 0);
|
if (buf) {
|
||||||
|
e->GetByteArrayRegion(a, 0, length, reinterpret_cast<jbyte*>(buf));
|
||||||
|
throwIOException(e, reinterpret_cast<const char*>(buf));
|
||||||
|
free(buf);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1841,6 +1841,7 @@ allocate(Thread* t, unsigned sizeInBytes, bool objectMask)
|
|||||||
{
|
{
|
||||||
return allocate2(t, sizeInBytes, objectMask);
|
return allocate2(t, sizeInBytes, objectMask);
|
||||||
} else {
|
} else {
|
||||||
|
assert(t, t->criticalLevel == 0);
|
||||||
return allocateSmall(t, sizeInBytes);
|
return allocateSmall(t, sizeInBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
test/Sockets.java
Normal file
33
test/Sockets.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user