@Override public int getRead() { Object v = getValue(); if (v instanceof RuntimeException) { throw (RuntimeException) v; } else if (v instanceof Error) { throw (Error) v; } else if (v instanceof Throwable) { throw new RuntimeSshException("Error reading from channel.", (Throwable) v); } else if (v instanceof Number) { return ((Number) v).intValue(); } else { throw formatExceptionMessage(IllegalStateException::new, "Unknown read value type: %s", (v == null) ? "null" : v.getClass().getName()); } }
@Override public IoReadFuture verify(long timeoutMillis) throws IOException { long startTime = System.nanoTime(); Number result = verifyResult(Number.class, timeoutMillis); long endTime = System.nanoTime(); if (debugEnabled) { log.debug("Read " + result + " bytes after " + (endTime - startTime) + " nanos"); } return this; }
session.exceptionCaught(e); future.setValue(nbRead);
session.exceptionCaught(e); future.setValue(nbRead);
@Override public IoReadFuture read(Buffer buf) { IoReadFutureImpl future = new IoReadFutureImpl(readFutureId, buf); if (isClosing()) { synchronized (buffer) { if (pending != null) { throw new ReadPendingException("Previous pending read not handled"); } if (buffer.available() > 0) { Buffer fb = future.getBuffer(); int nbRead = fb.putBuffer(buffer, false); buffer.compact(); future.setValue(nbRead); } else { future.setValue(new IOException("Closed")); } } } else { synchronized (buffer) { if (pending != null) { throw new ReadPendingException("Previous pending read not handled"); } pending = future; } doRead(false); } return future; }
@Override public IoReadFuture read(Buffer buf) { IoReadFutureImpl future = new IoReadFutureImpl(readFutureId, buf); if (isClosing()) { synchronized (buffer) { if (pending != null) { throw new ReadPendingException("Previous pending read not handled"); } if (buffer.available() > 0) { Buffer fb = future.getBuffer(); int nbRead = fb.putBuffer(buffer, false); buffer.compact(); future.setValue(nbRead); } else { future.setValue(new IOException("Closed")); } } } else { synchronized (buffer) { if (pending != null) { throw new ReadPendingException("Previous pending read not handled"); } pending = future; } doRead(false); } return future; }
@Override public int getRead() { Object v = getValue(); if (v instanceof RuntimeException) { throw (RuntimeException) v; } else if (v instanceof Error) { throw (Error) v; } else if (v instanceof Throwable) { throw new RuntimeSshException("Error reading from channel.", (Throwable) v); } else if (v instanceof Number) { return ((Number) v).intValue(); } else { throw formatExceptionMessage(IllegalStateException::new, "Unknown read value type: %s", (v == null) ? "null" : v.getClass().getName()); } }
@Override protected void preClose() { synchronized (buffer) { if (buffer.available() == 0) { if (pending != null) { pending.setValue(new SshException("Closed")); } } } super.preClose(); }
@Override public IoReadFuture verify(long timeoutMillis) throws IOException { long startTime = System.nanoTime(); Number result = verifyResult(Number.class, timeoutMillis); long endTime = System.nanoTime(); if (debugEnabled) { log.debug("Read " + result + " bytes after " + (endTime - startTime) + " nanos"); } return this; }
@Override public Throwable getException() { Object v = getValue(); if (v instanceof Throwable) { return (Throwable) v; } else { return null; } } }
@Override protected void preClose() { synchronized (buffer) { if (buffer.available() == 0) { if (pending != null) { pending.setValue(new SshException("Closed")); } } } super.preClose(); }
@Override public Throwable getException() { Object v = getValue(); if (v instanceof Throwable) { return (Throwable) v; } else { return null; } } }