Description
NioServerListener which extends Thread can't throw any exceptions because it swallows them in run() as follows.
try { // code for server bootstraping and binding } catch (Exception e) { e.printStackTrace(); }
This results in that startServer() can't catch BindException and retry to start the server recursively. There can be two options.
- Option 1. Use Thread.UncaughtExceptionHandler.
- Option 2. Make NioServerListener extend Callable and use get() of Future to catch exceptions.
I think Option 2 looks better because the code could be more intuitive.