mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
Code cleanup, add { to single-line if
This commit is contained in:
@@ -362,10 +362,12 @@ public abstract class AbstractChannel
|
|||||||
} catch (Buffer.BufferException be) {
|
} catch (Buffer.BufferException be) {
|
||||||
throw new ConnectionException(be);
|
throw new ConnectionException(be);
|
||||||
}
|
}
|
||||||
if (len < 0 || len > getLocalMaxPacketSize() || len > buf.available())
|
if (len < 0 || len > getLocalMaxPacketSize() || len > buf.available()) {
|
||||||
throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR, "Bad item length: " + len);
|
throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR, "Bad item length: " + len);
|
||||||
if (log.isTraceEnabled())
|
}
|
||||||
|
if (log.isTraceEnabled()) {
|
||||||
log.trace("IN #{}: {}", id, ByteArrayUtils.printHex(buf.array(), buf.rpos(), len));
|
log.trace("IN #{}: {}", id, ByteArrayUtils.printHex(buf.array(), buf.rpos(), len));
|
||||||
|
}
|
||||||
stream.receive(buf.array(), buf.rpos(), len);
|
stream.receive(buf.array(), buf.rpos(), len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,36 +92,43 @@ public final class ChannelInputStream
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
synchronized (buf) {
|
synchronized (buf) {
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
if (buf.available() > 0)
|
if (buf.available() > 0) {
|
||||||
break;
|
break;
|
||||||
if (eof)
|
}
|
||||||
if (error != null)
|
if (eof) {
|
||||||
|
if (error != null) {
|
||||||
throw error;
|
throw error;
|
||||||
else
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
buf.wait();
|
buf.wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw (IOException) new InterruptedIOException().initCause(e);
|
throw (IOException) new InterruptedIOException().initCause(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len > buf.available())
|
if (len > buf.available()) {
|
||||||
len = buf.available();
|
len = buf.available();
|
||||||
|
}
|
||||||
buf.readRawBytes(b, off, len);
|
buf.readRawBytes(b, off, len);
|
||||||
if (buf.rpos() > win.getMaxPacketSize() && buf.available() == 0)
|
if (buf.rpos() > win.getMaxPacketSize() && buf.available() == 0) {
|
||||||
buf.clear();
|
buf.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!chan.getAutoExpand())
|
if (!chan.getAutoExpand()) {
|
||||||
checkWindow();
|
checkWindow();
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void receive(byte[] data, int offset, int len)
|
public void receive(byte[] data, int offset, int len)
|
||||||
throws ConnectionException, TransportException {
|
throws ConnectionException, TransportException {
|
||||||
if (eof)
|
if (eof) {
|
||||||
throw new ConnectionException("Getting data on EOF'ed stream");
|
throw new ConnectionException("Getting data on EOF'ed stream");
|
||||||
|
}
|
||||||
synchronized (buf) {
|
synchronized (buf) {
|
||||||
buf.putRawBytes(data, offset, len);
|
buf.putRawBytes(data, offset, len);
|
||||||
buf.notifyAll();
|
buf.notifyAll();
|
||||||
@@ -132,9 +139,10 @@ public final class ChannelInputStream
|
|||||||
synchronized (win) {
|
synchronized (win) {
|
||||||
win.consume(len);
|
win.consume(len);
|
||||||
}
|
}
|
||||||
if (chan.getAutoExpand())
|
if (chan.getAutoExpand()) {
|
||||||
checkWindow();
|
checkWindow();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkWindow()
|
private void checkWindow()
|
||||||
throws TransportException {
|
throws TransportException {
|
||||||
|
|||||||
@@ -59,10 +59,11 @@ public abstract class Window {
|
|||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
size -= dec;
|
size -= dec;
|
||||||
log.debug("Consuming by {} down to {}", dec, size);
|
log.debug("Consuming by {} down to {}", dec, size);
|
||||||
if (size < 0)
|
if (size < 0) {
|
||||||
throw new ConnectionException("Window consumed to below 0");
|
throw new ConnectionException("Window consumed to below 0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
Reference in New Issue
Block a user