Broken Exception stack in HTTPUSocket

2003-10-16
2003-10-16
  • Hi,

    I think that the library has a minor bug when running 2 control points on the same machine. Starting up the second one triggers a biding exception and a couple of null pointer exceptions.

    The binding exception arises from trying to get a free SSDP socket; as there is already a control point running the first SSDP socket is taken. This is all good and I think that the expected behavior. However, the controlpoint class relies in that this exception is catched at the right level and converted to a boolean so that it can test for the next free socket.

    The Exception is caught too soon and although it does convert it to a boolean the callee function does not return that type. The location where the exception stack is stopped from going up is in HTTPUSocket::open(String, int)

    the code that I propose modifying is:

    public boolean open(String bindAddr, int bindPort)
           Throws Exception
        {
            close();
           
            try {
                InetSocketAddress bindSock = new InetSocketAddress(InetAddress.getByName(bindAddr), bindPort);
                ssdpUniSock = new DatagramSocket(bindSock);
            }
            catch (Exception e) {
                Debug.warning(e);
                throw new Exception(e.getCause());
            }
           
            setLocalAddress(bindAddr);       
        }

    and fixing the constructor to pass on the exception. I've tested it and it seems to work.

    hope this helps.
    Ricardo