@Override public void run() { try { while (!isStopped() && !isStopping()) { Socket sock = socketQueue.poll(1, TimeUnit.SECONDS); if (sock != null) { try { handleSocket(sock); } catch (Throwable thrown) { if (!isStopping()) { onAcceptError(new Exception(thrown)); } else if (!isStopped()) { LOG.warn("Unexpected error thrown during accept handling: ", thrown); onAcceptError(new Exception(thrown)); } } } } } catch (InterruptedException e) { if (!isStopped() || !isStopping()) { LOG.info("socketQueue interrupted - stopping"); onAcceptError(e); } } } };
private void doRunWithServerSocket(final ServerSocket serverSocket) { while (!isStopped()) { Socket socket = null; try { socket = serverSocket.accept(); if (socket != null) { if (isStopped() || getAcceptListener() == null) { socket.close(); } else { if (useQueueForAccept) { socketQueue.put(socket); } else { handleSocket(socket); } } } } catch (SocketTimeoutException ste) { // expect this to happen } catch (Exception e) { if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e); } } } }
while (!isStopped()) { int count = selector.select(10); SocketChannel sc = channel.accept(); if (sc != null) { if (isStopped() || getAcceptListener() == null) { sc.close(); } else { if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e); if (!isStopping()) { onAcceptError(ex); } else if (!isStopped()) { LOG.warn("run()", ex); onAcceptError(ex);
} else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e);
/** * pull Sockets from the ServerSocket */ @Override public void run() { if (!isStopped() && !isStopping()) { final ServerSocket serverSocket = this.serverSocket; if (serverSocket == null) { onAcceptError(new IOException("Server started without a valid ServerSocket")); } final ServerSocketChannel channel = serverSocket.getChannel(); if (channel != null) { doRunWithServerSocketChannel(channel); } else { doRunWithServerSocket(serverSocket); } } }
@Override public void run() { try { while (!isStopped() && !isStopping()) { Socket sock = socketQueue.poll(1, TimeUnit.SECONDS); if (sock != null) { try { handleSocket(sock); } catch (Throwable thrown) { if (!isStopping()) { onAcceptError(new Exception(thrown)); } else if (!isStopped()) { LOG.warn("Unexpected error thrown during accept handling: ", thrown); onAcceptError(new Exception(thrown)); } } } } } catch (InterruptedException e) { if (!isStopped() || !isStopping()) { LOG.info("socketQueue interrupted - stopping"); onAcceptError(e); } } } };
@Override public void run() { try { while (!isStopped() && !isStopping()) { Socket sock = socketQueue.poll(1, TimeUnit.SECONDS); if (sock != null) { try { handleSocket(sock); } catch (Throwable thrown) { if (!isStopping()) { onAcceptError(new Exception(thrown)); } else if (!isStopped()) { LOG.warn("Unexpected error thrown during accept handling: ", thrown); onAcceptError(new Exception(thrown)); } } } } } catch (InterruptedException e) { if (!isStopped() || !isStopping()) { LOG.info("socketQueue interrupted - stopping"); onAcceptError(e); } } } };
@Override public void run() { try { while (!isStopped() && !isStopping()) { Socket sock = socketQueue.poll(1, TimeUnit.SECONDS); if (sock != null) { try { handleSocket(sock); } catch (Throwable thrown) { if (!isStopping()) { onAcceptError(new Exception(thrown)); } else if (!isStopped()) { LOG.warn("Unexpected error thrown during accept handling: ", thrown); onAcceptError(new Exception(thrown)); } } } } } catch (InterruptedException e) { if (!isStopped() || !isStopping()) { LOG.info("socketQueue interrupted - stopping"); onAcceptError(e); } } } };
private void doRunWithServerSocket(final ServerSocket serverSocket) { while (!isStopped()) { Socket socket = null; try { socket = serverSocket.accept(); if (socket != null) { if (isStopped() || getAcceptListener() == null) { socket.close(); } else { if (useQueueForAccept) { socketQueue.put(socket); } else { handleSocket(socket); } } } } catch (SocketTimeoutException ste) { // expect this to happen } catch (Exception e) { if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e); } } } }
private void doRunWithServerSocket(final ServerSocket serverSocket) { while (!isStopped()) { Socket socket = null; try { socket = serverSocket.accept(); if (socket != null) { if (isStopped() || getAcceptListener() == null) { socket.close(); } else { if (useQueueForAccept) { socketQueue.put(socket); } else { handleSocket(socket); } } } } catch (SocketTimeoutException ste) { // expect this to happen } catch (Exception e) { if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e); } } } }
private void doRunWithServerSocket(final ServerSocket serverSocket) { while (!isStopped()) { Socket socket = null; try { socket = serverSocket.accept(); if (socket != null) { if (isStopped() || getAcceptListener() == null) { socket.close(); } else { if (useQueueForAccept) { socketQueue.put(socket); } else { handleSocket(socket); } } } } catch (SocketTimeoutException ste) { // expect this to happen } catch (Exception e) { if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e); } } } }
public void run() { try { while (!isStopped() && !isStopping()) { Socket sock = socketQueue.poll(1, TimeUnit.SECONDS); if (sock != null) { handleSocket(sock); } } } catch (InterruptedException e) { LOG.info("socketQueue interuppted - stopping"); if (!isStopping()) { onAcceptError(e); } } }
while (!isStopped()) { int count = selector.select(10); SocketChannel sc = channel.accept(); if (sc != null) { if (isStopped() || getAcceptListener() == null) { sc.close(); } else { if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e); if (!isStopping()) { onAcceptError(ex); } else if (!isStopped()) { LOG.warn("run()", ex); onAcceptError(ex);
} else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e);
} else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e);
if (!isStopping()) { onAcceptError(e); } else if (!isStopped()) { LOG.warn("run()", e); onAcceptError(e);
/** * pull Sockets from the ServerSocket */ @Override public void run() { if (!isStopped() && !isStopping()) { final ServerSocket serverSocket = this.serverSocket; if (serverSocket == null) { onAcceptError(new IOException("Server started without a valid ServerSocket")); } final ServerSocketChannel channel = serverSocket.getChannel(); if (channel != null) { doRunWithServerSocketChannel(channel); } else { doRunWithServerSocket(serverSocket); } } }
/** * pull Sockets from the ServerSocket */ @Override public void run() { if (!isStopped() && !isStopping()) { final ServerSocket serverSocket = this.serverSocket; if (serverSocket == null) { onAcceptError(new IOException("Server started without a valid ServerSocket")); } final ServerSocketChannel channel = serverSocket.getChannel(); if (channel != null) { doRunWithServerSocketChannel(channel); } else { doRunWithServerSocket(serverSocket); } } }
/** * pull Sockets from the ServerSocket */ @Override public void run() { if (!isStopped() && !isStopping()) { final ServerSocket serverSocket = this.serverSocket; if (serverSocket == null) { onAcceptError(new IOException("Server started without a valid ServerSocket")); } final ServerSocketChannel channel = serverSocket.getChannel(); if (channel != null) { doRunWithServerSocketChannel(channel); } else { doRunWithServerSocket(serverSocket); } } }