RFR: java/net/MulticastSocket/SetGetNetworkInterfaceTest.java throws java.net.SocketException: Cannot assign requested address

Alan Bateman Alan.Bateman at oracle.com
Thu Jan 2 09:08:55 PST 2014


On 02/01/2014 16:26, Mark Sheppard wrote:
> Hi Alan,
>   added an ExceptionDescribe to native code and an -Xcheck:jni to the 
> cmd line options to produce the
> following:
Thanks, it is clearer now.

What you have is okay but I guess I'm just concerned that 
mcast_set_if_by_if_v4 can potentially fail for reasons other than 
setsockopt failing. Also the IPv6 mcast functions are more complicated 
and can potential fail for many reasons. I realize this is going beyond 
the scope of what you are looking at but would it make sense for these 
mcast functions to return an int (0 for success, non-0 when they fail) 
and only return with a pending JNI exception if a JNI function has 
failed. In other words? In other words, move the throwing of the 
network/SocketException to the caller so that it clearer to anyone 
reading the code where the errors are handled. That would give you 
something like:

rc = mcast_set_if_by_addr_v4(...)
if ((*env)->ExceptionOccurred(env)) return;

I'm not suggesting this has to be done now but I think the real issue 
here is that this code needs a bit of a clean-up (as it has grow over time).

-Alan



More information about the net-dev mailing list