private void processSocket(Socket socket) { try { GetRequest request = GetRequest.read(socket.getInputStream()); String url = ProxyCacheUtils.decode(request.uri); if (pinger.isPingRequest(url)) { pinger.responseToPing(socket); } else { HttpProxyCacheServerClients clients = getClients(url); clients.processRequest(request, socket); } } catch (SocketException e) { // There is no way to determine that client closed connection http://stackoverflow.com/a/10241044/999458 // So just to prevent log flooding don't log stacktrace } catch (ProxyCacheException | IOException e) { onError(new ProxyCacheException("Error processing request", e)); } finally { releaseSocket(socket); HttpProxyCacheDebuger.printfLog("Opened connections: " + getClientsCount()); } }