6917317: (sctp) Remove dependency on handleSocketError
Reviewed-by: alanb
This commit is contained in:
parent
34b95319c2
commit
3e77553ac1
@ -110,6 +110,38 @@ jboolean loadSocketExtensionFuncs
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
jint
|
||||
handleSocketError(JNIEnv *env, jint errorValue)
|
||||
{
|
||||
char *xn;
|
||||
switch (errorValue) {
|
||||
case EINPROGRESS: /* Non-blocking connect */
|
||||
return 0;
|
||||
case EPROTO:
|
||||
xn= JNU_JAVANETPKG "ProtocolException";
|
||||
break;
|
||||
case ECONNREFUSED:
|
||||
xn = JNU_JAVANETPKG "ConnectException";
|
||||
break;
|
||||
case ETIMEDOUT:
|
||||
xn = JNU_JAVANETPKG "ConnectException";
|
||||
break;
|
||||
case EHOSTUNREACH:
|
||||
xn = JNU_JAVANETPKG "NoRouteToHostException";
|
||||
break;
|
||||
case EADDRINUSE: /* Fall through */
|
||||
case EADDRNOTAVAIL:
|
||||
xn = JNU_JAVANETPKG "BindException";
|
||||
break;
|
||||
default:
|
||||
xn = JNU_JAVANETPKG "SocketException";
|
||||
break;
|
||||
}
|
||||
errno = errorValue;
|
||||
JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
|
||||
return IOS_THROWN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_nio_ch_SctpNet
|
||||
* Method: init
|
||||
|
@ -192,6 +192,18 @@ public class Connect {
|
||||
testCCE(new Callable<Void>() {
|
||||
public Void call() throws IOException {
|
||||
cceChannel.finishConnect(); return null; } });
|
||||
|
||||
/* TEST 8: IOException: Connection refused. Exercises handleSocketError.
|
||||
* Assumption: no sctp socket listening on 3456 */
|
||||
SocketAddress addr = new InetSocketAddress("localhost", 3456);
|
||||
channel = SctpChannel.open();
|
||||
try {
|
||||
channel.connect(addr);
|
||||
fail("should have thrown ConnectException: Connection refused");
|
||||
} catch (IOException ioe) {
|
||||
pass();
|
||||
}
|
||||
|
||||
} catch (IOException ioe) {
|
||||
unexpected(ioe);
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user