+ @VisibleForTesting
+ public InetSocketAddress getLocalSocketAddress() {
+ return (InetSocketAddress) serverSocket.getLocalSocketAddress();
+ }
+
+ @Override
+ public void run() {
+ while (up) {
+ Socket acceptedSocket = null;
+ try {
+ acceptedSocket = serverSocket.accept();
+ } catch (IOException e) {
+ if (up == false) {
+ logger.trace("Exiting server thread", e);
+ } else {
+ logger.warn("Exception occurred during socket.accept", e);
+ }
+ }
+ if (acceptedSocket != null) {
+ try {
+ Handshaker task = new Handshaker(acceptedSocket, localAddress, sessionIdCounter.incrementAndGet(), authProvider, bossGroup);
+ handshakeExecutor.submit(task);
+ } catch (IOException e) {
+ logger.warn("Cannot set PEMHostKey, closing connection", e);
+ try {
+ acceptedSocket.close();
+ } catch (IOException e1) {
+ logger.warn("Ignoring exception while closing socket", e);
+ }
+ }
+ }
+ }
+ logger.debug("Server thread is exiting");
+ }