mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +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) {
|
||||
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);
|
||||
if (log.isTraceEnabled())
|
||||
}
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("IN #{}: {}", id, ByteArrayUtils.printHex(buf.array(), buf.rpos(), len));
|
||||
}
|
||||
stream.receive(buf.array(), buf.rpos(), len);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,36 +92,43 @@ public final class ChannelInputStream
|
||||
throws IOException {
|
||||
synchronized (buf) {
|
||||
for (; ; ) {
|
||||
if (buf.available() > 0)
|
||||
if (buf.available() > 0) {
|
||||
break;
|
||||
if (eof)
|
||||
if (error != null)
|
||||
}
|
||||
if (eof) {
|
||||
if (error != null) {
|
||||
throw error;
|
||||
else
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
buf.wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw (IOException) new InterruptedIOException().initCause(e);
|
||||
}
|
||||
}
|
||||
if (len > buf.available())
|
||||
if (len > buf.available()) {
|
||||
len = buf.available();
|
||||
}
|
||||
buf.readRawBytes(b, off, len);
|
||||
if (buf.rpos() > win.getMaxPacketSize() && buf.available() == 0)
|
||||
if (buf.rpos() > win.getMaxPacketSize() && buf.available() == 0) {
|
||||
buf.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (!chan.getAutoExpand())
|
||||
if (!chan.getAutoExpand()) {
|
||||
checkWindow();
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
public void receive(byte[] data, int offset, int len)
|
||||
throws ConnectionException, TransportException {
|
||||
if (eof)
|
||||
if (eof) {
|
||||
throw new ConnectionException("Getting data on EOF'ed stream");
|
||||
}
|
||||
synchronized (buf) {
|
||||
buf.putRawBytes(data, offset, len);
|
||||
buf.notifyAll();
|
||||
@@ -132,8 +139,9 @@ public final class ChannelInputStream
|
||||
synchronized (win) {
|
||||
win.consume(len);
|
||||
}
|
||||
if (chan.getAutoExpand())
|
||||
if (chan.getAutoExpand()) {
|
||||
checkWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkWindow()
|
||||
@@ -143,7 +151,7 @@ public final class ChannelInputStream
|
||||
if (adjustment > 0) {
|
||||
log.debug("Sending SSH_MSG_CHANNEL_WINDOW_ADJUST to #{} for {} bytes", chan.getRecipient(), adjustment);
|
||||
trans.write(new SSHPacket(Message.CHANNEL_WINDOW_ADJUST)
|
||||
.putUInt32(chan.getRecipient()).putUInt32(adjustment));
|
||||
.putUInt32(chan.getRecipient()).putUInt32(adjustment));
|
||||
win.expand(adjustment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,9 @@ public abstract class Window {
|
||||
synchronized (lock) {
|
||||
size -= dec;
|
||||
log.debug("Consuming by {} down to {}", dec, size);
|
||||
if (size < 0)
|
||||
if (size < 0) {
|
||||
throw new ConnectionException("Window consumed to below 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user