@Override public void write(int b) throws IOException { if (channel.isClosed() || channel.isClosing()) { throw new IOException("Channel (" + channel + ") is closing / closed on write single byte"); } if (b == (eofSignal & 0xff)) { log.info("Closing channel (" + channel + ") due to single byte EOF"); channel.close(true); } }
@Override public void write(int b) throws IOException { if (channel.isClosed() || channel.isClosing()) { throw new IOException("Channel (" + channel + ") is closing / closed on write single byte"); } if (b == (eofSignal & 0xff)) { log.info("Closing channel (" + channel + ") due to single byte EOF"); channel.close(true); } }
@Override public void write(int b) throws IOException { if (channel.isClosed() || channel.isClosing()) { throw new IOException("Channel (" + channel + ") is closing / closed on write single byte"); } if (b == (eofSignal & 0xff)) { log.info("Closing channel (" + channel + ") due to single byte EOF"); channel.close(true); } }
@Override public void write(byte[] b, int off, int len) throws IOException { if (channel.isClosed() || channel.isClosing()) { throw new IOException("Channel (" + channel + ") is closing / closed on write " + len + " bytes"); } if (len <= 0) { return; } int lastPos = off + len - 1; if ((b[lastPos] & 0xFF) == (eofSignal & 0xFF)) { log.info("Closing channel (" + channel + ") due to last byte EOF"); channel.close(true); } } }
@Override public void write(byte[] b, int off, int len) throws IOException { if (channel.isClosed() || channel.isClosing()) { throw new IOException("Channel (" + channel + ") is closing / closed on write " + len + " bytes"); } if (len <= 0) { return; } int lastPos = off + len - 1; if ((b[lastPos] & 0xFF) == (eofSignal & 0xFF)) { log.info("Closing channel (" + channel + ") due to last byte EOF"); channel.close(true); } } }
@Override public void write(byte[] b, int off, int len) throws IOException { if (channel.isClosed() || channel.isClosing()) { throw new IOException("Channel (" + channel + ") is closing / closed on write " + len + " bytes"); } if (len <= 0) { return; } int lastPos = off + len - 1; if ((b[lastPos] & 0xFF) == (eofSignal & 0xFF)) { log.info("Closing channel (" + channel + ") due to last byte EOF"); channel.close(true); } } }
1); if (stat.contains(ClientChannelEvent.CLOSED)) { channel.close(true);
@Test public void testClientWithHeartBeat() throws Exception { SshClient client = SshClient.setUpDefaultClient(); client.getProperties().put(ClientFactoryManager.HEARTBEAT_INTERVAL, "500"); client.start(); ClientSession session = client.connect("localhost", port).await().getSession(); session.authPassword("smx", "smx").await().isSuccess(); ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL); int state = channel.waitFor(ClientChannel.CLOSED, 2000); assertTrue((state & ClientChannel.CLOSED) == 0); channel.close(false); client.stop(); }
} finally { if (channel != null) { channel.close(true);
assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } finally { channel.close(false);
assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } finally { channel.close(false);
assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } finally { channel.close(false);