public static void close(Closeable... closeables) { if(closeables != null) { for(Closeable closeable : closeables) Util.close(closeable); } }
public static void closeReverse(Closeable... closeables) { if(closeables != null) { for(int i=closeables.length-1; i >= 0; i--) Util.close(closeables[i]); } }
protected void stopEventThread() { Thread tmp=event_loop_thread; looping=false; if(tmp != null) tmp.interrupt(); Util.close(channel); }
public void getState(OutputStream output) throws Exception { DataOutputStream out=new DataOutputStream(new BufferedOutputStream(output, 1000)); try { synchronized(nodes) { Util.objectToStream(nodes, out); } } finally { Util.close(out); } }
@Override public void stop() { if(running.compareAndSet(true, false)) { Util.close(conn); super.stop(); } }
protected void stop(boolean graceful) { if(acceptor != null && acceptor.isAlive()) Util.close(srv_sock); // this will terminate thread, peer will receive SocketException (socket close) synchronized(clients) { clients.forEach(client -> client.stopThread(graceful)); clients.clear(); } acceptor=null; }
public static XmlConfigurator getInstance(URL url, Boolean validate) throws java.io.IOException { InputStream is = url.openStream(); try { return getInstance(is, validate); } finally { Util.close(is); } }
public void stop() { Util.close(sock); sock=null; receiver=null; super.stop(); }
void stop() { if(disp != null) disp.stop(); Util.close(channel); }
@ManagedOperation public void stop() throws IOException { Util.close(srv_sock); thread=null; if(thread_pool instanceof ExecutorService) ((ExecutorService)thread_pool).shutdown(); }
@Override public void stop() { if(running.compareAndSet(true, false)) { Util.close(srv_sock); Util.interruptAndWaitToDie(acceptor); super.stop(); } }
@Override @ManagedOperation(description="Stops the server") public synchronized void stop() { super.stop(); if(running.compareAndSet(true, false)) Util.close(selector, channel); // closing the selector also stops the acceptor thread }
public void stop() { looping=false; try { JmxConfigurator.unregisterChannel(channel, Util.getMBeanServer(), "jgroups", "mperf"); } catch(Exception e) { e.printStackTrace(); } Util.close(channel); }
public void destroy() { stubManager.destroyStubs(); Util.close(sock); super.destroy(); }
protected Tuple<InputStream,Object> createStreamToProvider(final Address provider, final StateHeader hdr) { Util.close(input_stream); input_stream=new BlockingInputStream(buffer_size); return new Tuple<>(input_stream, null); }
public void stop() { super.stop(); if(srv_sock_handler != null) { srv_sock_handler.stop(); // should also close srv_sock srv_sock_handler=null; Util.close(srv_sock); // not needed, but second line of defense srv_sock=null; } }
protected synchronized void stopKeyserver() { if(srv_sock_handler != null) { log.debug("%s: ceasing to be the keyserver; closing the server socket", local_addr); srv_sock_handler.stop(); srv_sock_handler=null; } if(srv_sock != null) { Util.close(srv_sock); // should not be necessary (check) srv_sock=null; } }
public void closeConnection(Connection conn, Throwable ex) { Util.close(conn); notifyConnectionClosed(conn, ex.toString()); removeConnectionIfPresent(conn != null? conn.peerAddress() : null, conn); }
protected synchronized void becomeKeyserver() throws Exception { if(srv_sock == null || srv_sock.isClosed()) { log.debug("%s: becoming keyserver; creating server socket", local_addr); srv_sock=createServerSocket(); srv_sock_handler=new Runner(getThreadFactory(), SSL_KEY_EXCHANGE.class.getSimpleName() + "-runner", this::accept, () -> Util.close(srv_sock)); srv_sock_handler.start(); log.debug("SSL server socket listening on %s", srv_sock.getLocalSocketAddress()); } }