- else {
- // We're shutting down so an exception is expected as the socket's been closed.
- // Log to debug.
- logger.debug("Shutting down - got expected exception: " + 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);
+ }