@Override public void run() { isRunning = true; while (isRunning) { try { LOGGER.info("Waiting for connection..."); socketServer.acceptConnection(); LOGGER.info("Connection accepted, receiving request..."); Request<T> request = socketServer.handle(); LOGGER.info("Handled request '" + request.getType() + "'."); } catch (SocketException se) { LOGGER.error("Error in connection.", se); } catch (IOException ioe) { LOGGER.error("Error in I/O.", ioe); } catch (ClassNotFoundException e) { LOGGER.error("Unsupported request sent.", e); } // Closing the connection in a separate block try { socketServer.endConnection(); LOGGER.info("Connection closed."); } catch (IOException e) { LOGGER.error("Error in I/O while closing connection.", e); } } }