Fixed more warnings

This commit is contained in:
Jeroen van Erp
2017-01-23 14:40:33 +01:00
parent 8134113510
commit ef3f7a2eaf
8 changed files with 31 additions and 19 deletions

View File

@@ -62,8 +62,11 @@ public class IdentificationStringParser {
} }
} }
private void logHeaderLine(Buffer.PlainBuffer lineBuffer) { private void logHeaderLine(Buffer.PlainBuffer lineBuffer) throws Buffer.BufferException {
byte[] bytes = new byte[lineBuffer.available()];
lineBuffer.readRawBytes(bytes);
String header = new String(bytes, 0, bytes.length - 1);
log.debug("Received header: {}", header);
} }
private String readIdentification(Buffer.PlainBuffer lineBuffer) throws Buffer.BufferException, TransportException { private String readIdentification(Buffer.PlainBuffer lineBuffer) throws Buffer.BufferException, TransportException {

View File

@@ -254,7 +254,7 @@ public class SecurityUtils {
throw new SSHRuntimeException("Failed to register BouncyCastle as the defaut JCE provider"); throw new SSHRuntimeException("Failed to register BouncyCastle as the defaut JCE provider");
} }
} }
registrationDone = true;
} }
registrationDone = true;
} }
} }

View File

@@ -329,6 +329,8 @@ public abstract class AbstractChannel
protected void gotUnknown(Message msg, SSHPacket buf) protected void gotUnknown(Message msg, SSHPacket buf)
throws ConnectionException, TransportException { throws ConnectionException, TransportException {
log.warn("Got unknown packet with type {}", msg);
} }
protected void handleRequest(String reqType, SSHPacket buf) protected void handleRequest(String reqType, SSHPacket buf)

View File

@@ -24,10 +24,11 @@ import java.io.InputStream;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class PacketReader public class PacketReader extends Thread {
extends Thread {
/** Logger */ /**
* Logger
*/
private final Logger log; private final Logger log;
private final InputStream in; private final InputStream in;
@@ -63,7 +64,7 @@ public class PacketReader
| lenBuf[3] & 0x000000ffL); | lenBuf[3] & 0x000000ffL);
if (len > SFTPPacket.MAX_SIZE) { if (len > SFTPPacket.MAX_SIZE) {
throw new SSHException(String.format("Indicated packet length %d too large", len)); throw new SSHException(String.format("Indicated packet length %d too large", len));
} }
return (int) len; return (int) len;
@@ -99,7 +100,7 @@ public class PacketReader
log.debug("Received {} packet", resp.getType()); log.debug("Received {} packet", resp.getType());
if (promise == null) if (promise == null)
throw new SFTPException("Received [" + resp.readType() + "] response for request-id " + resp.getRequestID() throw new SFTPException("Received [" + resp.readType() + "] response for request-id " + resp.getRequestID()
+ ", no such request was made"); + ", no such request was made");
else else
promise.deliver(resp); promise.deliver(resp);
} }

View File

@@ -81,10 +81,10 @@ public class RemoteFile
protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] data, int off, int len) protected Promise<Response, SFTPException> asyncWrite(long fileOffset, byte[] data, int off, int len)
throws IOException { throws IOException {
return requester.request(newRequest(PacketType.WRITE) return requester.request(newRequest(PacketType.WRITE)
.putUInt64(fileOffset) .putUInt64(fileOffset)
// TODO The SFTP spec claims this field is unneeded...? See #187 // TODO The SFTP spec claims this field is unneeded...? See #187
.putUInt32(len) .putUInt32(len)
.putRawBytes(data, off, len) .putRawBytes(data, off, len)
); );
} }
@@ -194,10 +194,10 @@ public class RemoteFile
@Override @Override
public long skip(long n) throws IOException { public long skip(long n) throws IOException {
final long fileLength = length(); final long fileLength = length();
final Long previousFileOffset = fileOffset; final Long previousFileOffset = fileOffset;
fileOffset = Math.min(fileOffset + n, fileLength); fileOffset = Math.min(fileOffset + n, fileLength);
return fileOffset - previousFileOffset; return fileOffset - previousFileOffset;
} }
@Override @Override
@@ -341,7 +341,7 @@ public class RemoteFile
public int available() throws IOException { public int available() throws IOException {
boolean lastRead = true; boolean lastRead = true;
while (!eof && (pending.available() <= 0) && lastRead) { while (!eof && (pending.available() <= 0) && lastRead) {
lastRead = retrieveUnconfirmedRead(false /*blocking*/); lastRead = retrieveUnconfirmedRead(false /*blocking*/);
} }
return pending.available(); return pending.available();
} }

View File

@@ -46,10 +46,12 @@ public class NoneCipher
@Override @Override
public void init(Mode mode, byte[] bytes, byte[] bytes1) { public void init(Mode mode, byte[] bytes, byte[] bytes1) {
// Nothing to do
} }
@Override @Override
public void update(byte[] input, int inputOffset, int inputLen) { public void update(byte[] input, int inputOffset, int inputLen) {
// Nothing to do
} }
} }

View File

@@ -70,7 +70,9 @@ public class BogusGSSContext
} }
@Override @Override
public void dispose() throws GSSException {} public void dispose() throws GSSException {
// Nothing to do
}
@Override @Override
public int getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize) throws GSSException { public int getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize) throws GSSException {

View File

@@ -34,7 +34,9 @@ public class BogusGSSCredential
} }
@Override @Override
public void dispose() throws GSSException {} public void dispose() throws GSSException {
// Nothing to do
}
@Override @Override
public GSSName getName() throws GSSException { public GSSName getName() throws GSSException {