I am using the following Code for Checking Address Resusability:-
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket
The javadocs for setReuseAddress
say:
When a TCP connection is closed the connection may remain in a timeout state for a period of time after the connection is closed (typically known as the TIME_WAIT state or 2MSL wait state). For applications using a well known socket address or port it may not be possible to bind a socket to the required SocketAddress if there is a connection in the timeout state involving the socket address or port.
Enabling SO_REUSEADDR prior to binding the socket using bind(SocketAddress) allows the socket to be bound even though a previous connection is in a timeout state.
But what you are doing does not match this use-case. You are not attempting to bind while some other socket is closing. You are actually trying to bind while another socket is open.
What puzzles me is why your test actually worked on older JREs. It might be a JVM bug ...