@Override public void close() throws IOException { synchronized (this) { if (running) { running = false; timeoutTimer.cancel(); server.close(); synchronized (clients) { List<ServerConnection> copy = new ArrayList<>(clients); clients.clear(); for (ServerConnection client : copy) { client.close(); } } } } if (serverThread != null) { try { serverThread.join(); } catch (InterruptedException ie) { // no-op } } }
@Override public void close() throws IOException { synchronized (this) { if (running) { running = false; timeoutTimer.cancel(); server.close(); synchronized (clients) { List<ServerConnection> copy = new ArrayList<>(clients); clients.clear(); for (ServerConnection client : copy) { client.close(); } } } } if (serverThread != null) { try { serverThread.join(); } catch (InterruptedException ie) { // no-op } } }
@Override public void close() throws IOException { synchronized (this) { if (!running) { return; } running = false; } synchronized(LauncherServer.class) { serverInstance = null; } timeoutTimer.cancel(); server.close(); synchronized (clients) { List<ServerConnection> copy = new ArrayList<>(clients); clients.clear(); for (ServerConnection client : copy) { client.close(); } } if (serverThread != null) { try { serverThread.join(); } catch (InterruptedException ie) { // no-op } } }
timeout.cancel(); close(); if (handle != null) { handle.dispose();
timeout.cancel(); close(); if (handle != null) { handle.dispose();
timeout.cancel(); close(); } finally { timeoutTimer.purge();
timeout.cancel(); close(); } finally { timeoutTimer.purge();
@Override public void close() throws IOException { synchronized (this) { if (!running) { return; } running = false; } synchronized(LauncherServer.class) { serverInstance = null; } timeoutTimer.cancel(); server.close(); synchronized (clients) { List<ServerConnection> copy = new ArrayList<>(clients); clients.clear(); for (ServerConnection client : copy) { client.close(); } } if (serverThread != null) { try { serverThread.join(); } catch (InterruptedException ie) { // no-op } } }
/** * Wait for the remote side to close the connection so that any pending data is processed. * This ensures any changes reported by the child application take effect. * * This method allows a short period for the above to happen (same amount of time as the * connection timeout, which is configurable). This should be fine for well-behaved * applications, where they close the connection arond the same time the app handle detects the * app has finished. * * In case the connection is not closed within the grace period, this method forcefully closes * it and any subsequent data that may arrive will be ignored. */ public void waitForClose() throws IOException { Thread connThread = this.connectionThread; if (Thread.currentThread() != connThread) { try { connThread.join(getConnectionTimeout()); } catch (InterruptedException ie) { // Ignore. } if (connThread.isAlive()) { LOG.log(Level.WARNING, "Timed out waiting for child connection to close."); close(); } } }
/** * Wait for the remote side to close the connection so that any pending data is processed. * This ensures any changes reported by the child application take effect. * * This method allows a short period for the above to happen (same amount of time as the * connection timeout, which is configurable). This should be fine for well-behaved * applications, where they close the connection arond the same time the app handle detects the * app has finished. * * In case the connection is not closed within the grace period, this method forcefully closes * it and any subsequent data that may arrive will be ignored. */ public void waitForClose() throws IOException { Thread connThread = this.connectionThread; if (Thread.currentThread() != connThread) { try { connThread.join(getConnectionTimeout()); } catch (InterruptedException ie) { // Ignore. } if (connThread.isAlive()) { LOG.log(Level.WARNING, "Timed out waiting for child connection to close."); close(); } } }
@Override public synchronized void disconnect() { if (connection != null && connection.isOpen()) { try { connection.close(); } catch (IOException ioe) { // no-op. } } dispose(); }
@Override public synchronized void disconnect() { if (connection != null && connection.isOpen()) { try { connection.close(); } catch (IOException ioe) { // no-op. } } dispose(); }