Move test for uninitialised mdp port to throw in more cases

This commit is contained in:
Jeremy Lakeman 2018-01-03 11:59:07 +10:30
parent dc0c0f86d8
commit fbbbfdacc7

View File

@ -66,8 +66,6 @@ public class MdpSocket{
bind(SubscriberId.ANY, port);
}
public synchronized void bind(SubscriberId sid, int port) throws IOException {
if (loopbackMdpPort==0)
throw new IOException("Loopback MDP port has not been set");
if (sid==null)
throw new NullPointerException();
if (sid.equals(this.sid) && this.port == port)
@ -109,6 +107,8 @@ public class MdpSocket{
public SelectableChannel getChannel() throws IOException {
if (channel == null){
if (loopbackMdpPort==0)
throw new IOException("Loopback MDP port has not been set");
channel = DatagramChannel.open();
channel.connect(new InetSocketAddress(loopback, loopbackMdpPort));
}