[ https://issues.apache.org/jira/browse/SSHD-1010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17125888#comment-17125888 ]
Guillaume Nodet commented on SSHD-1010: --------------------------------------- Basically, I don't think there is a single usage in SSHD where it actually makes sense. The {{SIZE}} refers to the number of bits and we always think in terms of bytes. So for each, one we should: * either use {{Xxx.BYTES}} if the size of the Byte/Integer/Long is referred to * use a literal value (such as 32) when this is a default value (for example a default buffer size) which has no relation to the Byte/Integer/Long type The tests are quite stable when using PRs now, so I'm quite confident that if a PR passes the checks, it's good to go. Below is the full list of {{Xxx.BYTES}} usage: {code} sshd-scp/src/test/java/org/apache/sshd/server/scp/ScpCommandFactoryTest.java 66: int sendSize = receiveSize + Long.SIZE; sshd-scp/src/test/java/org/apache/sshd/client/scp/ScpTest.java 216: StringBuilder sb = new StringBuilder(remotePath.length() + Long.SIZE); 217: for (int i = 0; i < Math.max(Long.SIZE, remoteComps.length); i++) { 244: int slashes = 1 /* at least one slash */ + rnd.random(Byte.SIZE); sshd-scp/src/main/java/org/apache/sshd/client/scp/ScpClient.java 154: StringBuilder sb = new StringBuilder(remote.length() + Long.SIZE).append(ScpHelper.SCP_COMMAND_PREFIX); 171: StringBuilder sb = new StringBuilder(remote.length() + Long.SIZE).append(ScpHelper.SCP_COMMAND_PREFIX); sshd-common/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java 66: for (int index = 0; index < Long.SIZE; index++) { 109: int slashes = 1 /* at least one slash */ + rnd.nextInt(Byte.SIZE); sshd-common/src/test/java/org/apache/sshd/common/util/security/SecurityProviderRegistrarTestSupport.java 44: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/util/io/IoUtilsTest.java 54: for (int index = 1; index < Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/util/io/NullInputStreamTest.java 51: assertEquals(-1, INSTANCE.read(new byte[Byte.SIZE])); 56: byte[] buf = new byte[Byte.SIZE]; 62: assertEquals(0L, INSTANCE.skip(Long.SIZE)); 83: byte[] buf = new byte[Byte.SIZE]; 99: long skip = stream.skip(Long.SIZE); sshd-common/src/test/java/org/apache/sshd/common/util/io/LimitInputStreamTest.java 99: readLen = (int) limited.skip(Byte.SIZE); sshd-common/src/test/java/org/apache/sshd/common/util/io/EmptyInputStreamTest.java 66: in.mark(Long.SIZE); 88: byte[] bytes = new byte[Byte.SIZE]; sshd-common/src/test/java/org/apache/sshd/common/util/io/DirectoryScannerTest.java 82: for (int level = 1; level <= Byte.SIZE; level++) { sshd-common/src/test/java/org/apache/sshd/common/util/io/NullOutputStreamTest.java 56: byte[] buf = new byte[Byte.SIZE]; sshd-common/src/test/java/org/apache/sshd/common/util/Int2IntFunctionTest.java 44: int factor = Byte.SIZE; 46: for (int index = 1, sum = 0; index <= Byte.SIZE; index++) { 56: for (int index = 1; index <= Byte.SIZE; index++) { 65: int factor = Byte.SIZE; 67: for (int index = 1, sum = 0; index <= Byte.SIZE; index++) { 77: for (int index = 1; index <= Byte.SIZE; index++) { 88: for (int index = 1, mul = 1, expected = factor; index <= Byte.SIZE; index++, expected *= factor) { 98: for (int index = 1; index <= Byte.SIZE; index++) { 109: for (int index = 1; index <= Byte.SIZE; index++) { 121: for (int index = 1; index <= Byte.SIZE; index++) { 132: for (int index = 1, quot = 65536, expected = quot / factor; index <= Byte.SIZE; index++, expected /= factor) { 142: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/util/NumberUtilsTest.java 42: for (int index = 0; index < Integer.SIZE; expected <<= 1, index++) { 55: int expected = Integer.MAX_VALUE - Byte.SIZE; sshd-common/src/test/java/org/apache/sshd/common/util/EventListenerUtilsTest.java 49: for (int index = 0; index < Byte.SIZE; index++) { 104: for (int index = 1; index <= Byte.SIZE; index++) { 112: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/util/buffer/BufferTest.java 56: Buffer buffer = new ByteArrayBuffer(Integer.SIZE); 68: Buffer buffer = new ByteArrayBuffer(expected.length() + Byte.SIZE); 79: Buffer buffer = new ByteArrayBuffer(chars.length + Byte.SIZE); 94: Buffer buffer = new ByteArrayBuffer(bytes.length + Byte.SIZE); sshd-common/src/test/java/org/apache/sshd/common/util/buffer/BufferUtilsTest.java 59: final int testOffset = Byte.SIZE / 2; sshd-common/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java 123: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscatorTest.java 70: assertEquals("Not a BYTE size multiple", 0, keyLength % Byte.SIZE); sshd-common/src/test/java/org/apache/sshd/common/keyprovider/MultiKeyIdentityProviderTest.java 54: for (int index = 1; index <= Short.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/channel/PtyModeValueTest.java 78: for (int index = 0; index < Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java 140: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/compression/BuiltinCompressionsTest.java 145: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/common/future/DefaultSshFutureTest.java 75: int numListeners = Byte.SIZE; 107: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcherTest.java 99: for (int index = 1; index < Byte.SIZE; index++) { 104: for (int index = 1; index < Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/client/config/keys/LazyClientIdentityIteratorTest.java 51: for (int index = 1; index <= Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java 125: for (int index = 0; index < Byte.SIZE; index++) { 137: for (int index = 0; index < Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolverTest.java 117: for (int index = 1; index < Byte.SIZE; index++) { sshd-common/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java 52: StringBuilder sb = new StringBuilder(testHost.length() + Byte.SIZE); 84: StringBuilder sb = new StringBuilder(pkgName.length() + Long.SIZE + 1).append(HostPatternsHolder.WILDCARD_PATTERN); sshd-common/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java 46: private Buffer buffer = new ByteArrayBuffer(Integer.SIZE, false); 126: Buffer buf = new ByteArrayBuffer(org.available() + Byte.SIZE, false); sshd-common/src/main/java/org/apache/sshd/common/util/NumberUtils.java 140: StringBuilder sb = new StringBuilder(values.length * Byte.SIZE); 156: StringBuilder sb = new StringBuilder(values.length * Byte.SIZE); 172: StringBuilder sb = new StringBuilder(values.length * Byte.SIZE); 188: StringBuilder sb = new StringBuilder(values.length * Byte.SIZE); 204: StringBuilder sb = new StringBuilder(values.length * Byte.SIZE); 220: StringBuilder sb = new StringBuilder(values.length * Byte.SIZE); sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityUtils.java 311: ValidateUtils.checkTrue(maxKeySize > Byte.SIZE, "Invalid max. key size: %d", maxKeySize); sshd-common/src/main/java/org/apache/sshd/common/util/io/IoUtils.java 599: List<String> result = new ArrayList<>(Math.max(lineCountHint, Short.SIZE)); sshd-common/src/main/java/org/apache/sshd/common/util/buffer/BufferUtils.java 93: StringBuilder sb = new StringBuilder(chunkSize * 3 /* HEX */ + prefix.length() + Long.SIZE /* some extra */); 521: return (value < Byte.SIZE) 522: ? Byte.SIZE sshd-common/src/main/java/org/apache/sshd/common/util/buffer/Buffer.java 268: short v = (short) ((workBuf[1] << Byte.SIZE) & 0xFF00); sshd-common/src/main/java/org/apache/sshd/common/signature/SignatureRSA.java 76: return (modulus.bitLength() + Byte.SIZE - 1) / Byte.SIZE; sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java 59: byte[] keyValue = deriveEncryptionKey(encContext, keyLength / Byte.SIZE); 132: byte[] keyAsBytes = new byte[keyLength / Byte.SIZE]; sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/DESPrivateKeyObfuscator.java 46: return applyPrivateKeyCipher(bytes, effContext, keyValue.length * Byte.SIZE, keyValue, encryptIt); sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java 538: try (ByteArrayOutputStream baos = new ByteArrayOutputStream((2 * 66) + Long.SIZE)) { sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostPatternValue.java 82: StringBuilder sb = new StringBuilder(GenericUtils.length(purePattern) + Short.SIZE); sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java 1068: StringBuilder sb = new StringBuilder(path.length() + Long.SIZE); sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/DefaultCloseableHandleTest.java 82: for (int index = 0; index < Byte.SIZE; index++) { sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/UnsupportedExtensionTest.java 51: Buffer buffer = new ByteArrayBuffer(Integer.BYTES + GenericUtils.length(opcode) + Byte.SIZE, false); sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java 74: Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE)); sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java 70: Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE)); sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java 328: StringBuilder sb = new StringBuilder(Long.SIZE + 1); 330: for (int i = 0; i < Long.SIZE; i++) { 380: if (rnd.random(Byte.SIZE) < (Byte.SIZE / 2)) { 393: int slashes = 1 /* at least one slash */ + rnd.random(Byte.SIZE); 545: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE, false); 1427: final int sizeFactor = Short.SIZE; 1428: byte[] workBuf = new byte[IoUtils.DEFAULT_COPY_SIZE * Short.SIZE]; sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpFileSystemAccessor.java 80: .put("size", FileInfoExtractor.SIZE) sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java 579: buffer.ensureCapacity(readLen + Long.SIZE /* the header */, IntUnaryOperator.identity()); sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java 295: Buffer b = new ByteArrayBuffer(msglen + Integer.BYTES + Long.SIZE /* a bit extra */, false); sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpHelper.java 1119: + Integer.SIZE); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/AbstractSftpClient.java 72: public static final int DEFAULT_WRITE_CHUNK_SIZE = SshConstants.SSH_REQUIRED_PAYLOAD_PACKET_LENGTH_SUPPORT - Long.SIZE; 653: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false); 728: Buffer buffer = new ByteArrayBuffer(id.length + Long.SIZE /* some extra fields */, false); 743: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false); 758: Buffer buffer = new ByteArrayBuffer(oldPath.length() + newPath.length() + Long.SIZE /* some extra fields */, false); 799: Buffer buffer = new ByteArrayBuffer(id.length + Long.SIZE /* some extra fields */, false); 903: Buffer buffer = new ByteArrayBuffer(id.length + writeSize + Long.SIZE /* some extra fields */, false); 931: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false); 953: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false); 964: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false); 985: Buffer buffer = new ByteArrayBuffer(id.length + Byte.SIZE /* some extra fields */, false); 1117: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE, false); 1128: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE, false); 1145: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE, false); 1163: Buffer buffer = new ByteArrayBuffer(id.length + Byte.SIZE /* a bit extra */, false); 1200: Buffer buffer = new ByteArrayBuffer(id.length + (2 * Long.SIZE) /* some extras */, false); 1212: Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false); 1227: Buffer buffer = new ByteArrayBuffer(linkPath.length() + targetPath.length() + Long.SIZE /* some extra fields */, false); 1260: Buffer buffer = new ByteArrayBuffer(id.length + Long.SIZE /* a bit extra */, false); 1279: Buffer buffer = new ByteArrayBuffer(id.length + Long.SIZE /* a bit extra */, false); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/SftpOutputStreamAsync.java 159: buf = new ByteArrayBuffer(id.length + avail + Long.SIZE /* some extra fields */, false); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java 242: Buffer buffer = new ByteArrayBuffer(incoming.available() + Long.SIZE, false); 529: + Integer.BYTES + verVal.length() + Byte.SIZE, 554: Channel.CHANNEL_SUBSYSTEM.length() + systemName.length() + Integer.SIZE); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtension.java 42: Buffer buffer = getCommandBuffer(target, Long.SIZE + 2 * Long.BYTES + Integer.BYTES + NumberUtils.length(quickHash)); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractSftpClientExtension.java 167: Buffer buffer = new ByteArrayBuffer(Integer.BYTES + GenericUtils.length(opcode) + extraSize + Byte.SIZE, false); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImpl.java 51: + (3 * (Long.SIZE + Integer.BYTES))); sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/fs/SftpFileSystemProvider.java 1352: StringBuilder sb = new StringBuilder(numParams * Short.SIZE); sshd-contrib/src/test/java/org/apache/sshd/common/channel/throttle/ThrottlingPacketWriterTest.java 56: = new ThrottlingPacketWriter(new MockPacketWriter(), Byte.SIZE, TimeUnit.SECONDS.toMillis(3L))) { 59: Buffer buf = new ByteArrayBuffer(Byte.SIZE); 90: = new ThrottlingPacketWriter(new MockPacketWriter(), Byte.SIZE, TimeUnit.SECONDS.toMillis(3L))) { 95: IoWriteFuture future = throttler.writePacket(new ByteArrayBuffer(Byte.SIZE)); 103: = new ThrottlingPacketWriter(new MockPacketWriter(), Byte.SIZE, TimeUnit.SECONDS.toMillis(3L))) { 106: IoWriteFutureImpl futureImpl = (IoWriteFutureImpl) throttler.writePacket(new ByteArrayBuffer(Byte.SIZE)); 110: IoWriteFuture future = throttler.writePacket(new ByteArrayBuffer(Byte.SIZE)); sshd-contrib/src/main/java/org/apache/sshd/common/util/io/LineOutputStream.java 96: byte[] tmp = new byte[reqLen + Byte.SIZE /* a bit extra to avoid frequent re-sizing */]; sshd-contrib/src/main/java/org/apache/sshd/common/signature/LegacyDSASigner.java 143: byte[] kValue = new byte[q.bitLength() / Byte.SIZE]; 170: int nBytes = q.bitLength() / Byte.SIZE; 269: int nBytes = q.bitLength() / Byte.SIZE; sshd-spring-sftp/src/test/java/org/apache/sshd/spring/integration/sftp/ApacheSshdSftpSessionFactoryTest.java 166: for (int index = 1; index <= Byte.SIZE; index++) { 266: for (int index = 1; index <= Byte.SIZE; index++) { 273: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java 236: byte[] data = new byte[bytes.length + Long.SIZE]; sshd-core/src/test/java/org/apache/sshd/ProxyTest.java 264: byte[] buf = new byte[bytes.length + Long.SIZE]; sshd-core/src/test/java/org/apache/sshd/server/auth/BuiltinUserAuthFactoriesTest.java 96: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/server/shell/InvertedShellWrapperTest.java 190: try (InputStream stdin = newDelayedInputStream(Long.SIZE, inputContent); 192: InputStream shellOut = newDelayedInputStream(Byte.SIZE, outputContent); 193: ByteArrayOutputStream stdout = new ByteArrayOutputStream(outputContent.length() + Byte.SIZE); 194: InputStream shellErr = newDelayedInputStream(Short.SIZE, errorContent); 195: ByteArrayOutputStream stderr = new ByteArrayOutputStream(errorContent.length() + Byte.SIZE)) { sshd-core/src/test/java/org/apache/sshd/server/kex/ModuliTest.java 65: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/server/PasswordAuthenticatorTest.java 64: for (int index = 0; index < Long.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/server/ServerSessionListenerTest.java 138: for (int retryCount = 0; retryCount < Byte.SIZE; retryCount++) { sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java 738: blobLen + alg.length() + Long.SIZE); sshd-core/src/test/java/org/apache/sshd/common/cipher/BuiltinCiphersTest.java 267: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java 153: byte[] actData = new byte[expData.length + Long.SIZE /* just in case */]; sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java 140: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java 52: byte[] readBytes = new byte[b.length + Long.SIZE]; 66: for (int index = 0; index < Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/common/mac/MacCompatibilityTest.java 213: byte[] data = new byte[bytes.length + Long.SIZE]; sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java 154: byte[] data = new byte[bytes.length + Long.SIZE]; sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java 290: byte[] buf = new byte[bytes.length + Long.SIZE]; 327: byte[] buf = new byte[bytes.length + Long.SIZE]; 357: byte[] buf = new byte[bytes.length + Long.SIZE]; 467: byte[] buf = new byte[bytes.length + Long.SIZE]; 509: byte[] buf = new byte[bytes.length + Long.SIZE]; 625: byte[] buf = new byte[bytes.length + Long.SIZE]; 661: byte[] buf = new byte[bytes.length + Long.SIZE]; 703: byte[] buf = new byte[bytes.length + Long.SIZE]; sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingLoadTest.java 348: int startPos = Math.max(0, index - Byte.SIZE); 349: int endPos = Math.min(startPos + Short.SIZE, expectedBytes.length); 350: if ((endPos - startPos) < Byte.SIZE) { 351: startPos = expectedBytes.length - Byte.SIZE; sshd-core/src/test/java/org/apache/sshd/common/session/ReservedSessionMessagesHandlerTest.java 145: for (int index = 1; index <= Byte.SIZE; index++) { 172: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java 128: StringBuilder sb = new StringBuilder(SessionContext.MAX_VERSION_LINE_LENGTH + Integer.SIZE); 149: StringBuilder sb = new StringBuilder(FactoryManager.DEFAULT_MAX_IDENTIFICATION_SIZE + Integer.SIZE); 162: final long frequency = Byte.SIZE; 163: PropertyResolverUtils.updateProperty(session, FactoryManager.IGNORE_MESSAGE_SIZE, Short.SIZE); 168: Buffer msg = session.createBuffer(SshConstants.SSH_MSG_DEBUG, Long.SIZE); 176: for (int cycle = 0; cycle < Byte.SIZE; cycle++) { 188: len >= Short.SIZE); 194: assertEquals("Mismatched number of ignore messages", Byte.SIZE, numIgnores); 218: Buffer buffer = new ByteArrayBuffer(Long.SIZE); 234: Buffer buffer = new ByteArrayBuffer(Long.SIZE); 250: Buffer buffer = new ByteArrayBuffer(Long.SIZE + Byte.MAX_VALUE); 267: Buffer buffer = new ByteArrayBuffer(Long.SIZE + Byte.MAX_VALUE); 289: Buffer buffer = new ByteArrayBuffer(Long.SIZE); 294: buffer.putInt(Byte.SIZE + 1); // bad language tag length 295: for (int index = 0; index < Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/client/auth/BuiltinUserAuthFactoriesTest.java 94: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/client/keyverifier/StaticServerKeyVerifierTest.java 71: for (int index = 0; index < Long.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java 1414: Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_DISCONNECT, Integer.SIZE); sshd-core/src/test/java/org/apache/sshd/client/channel/ChannelExecTest.java 95: for (int index = 1; index <= Byte.SIZE; index++) { sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java 83: Buffer bs2 = new ByteArrayBuffer(keyType.length() + signature.length + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/server/auth/password/UserAuthPassword.java 180: GenericUtils.length(prompt) + GenericUtils.length(lang) + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/server/auth/gss/UserAuthGSS.java 111: Buffer b = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_INFO_REQUEST, out.length + Integer.SIZE); 185: Buffer b = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE, out.length + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/server/auth/hostbased/UserAuthHostBased.java 164: buf = new ByteArrayBuffer(dataLen + id.length + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/server/auth/pubkey/UserAuthPublicKey.java 168: + alg.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE, 200: GenericUtils.length(alg) + blobLen + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/server/shell/InvertedShellWrapper.java 115: ValidateUtils.checkTrue(bufferSize > Byte.SIZE, "Copy buffer size too small: %d", bufferSize); sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java 279: ValidateUtils.checkTrue(len <= (Integer.MAX_VALUE - Long.SIZE), 282: receiverBuffer = new ByteArrayBuffer(reqLen + Long.SIZE, false); 290: ValidateUtils.checkTrue(len <= (Integer.MAX_VALUE - Long.SIZE), 311: extendedDataBuffer = new ByteArrayBuffer(totalSize + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java 116: SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE); sshd-core/src/main/java/org/apache/sshd/server/x11/ChannelForwardedX11.java 68: remoteHost.length() + type.length() + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/server/x11/DefaultX11ForwardSupport.java 206: Buffer buffer = new ByteArrayBuffer(message.available() + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/server/global/TcpipForwardHandler.java 45: public static final IntUnaryOperator RESPONSE_BUFFER_GROWTH_FACTOR = Int2IntFunction.add(Byte.SIZE); sshd-core/src/main/java/org/apache/sshd/server/global/CancelTcpipForwardHandler.java 44: public static final IntUnaryOperator RESPONSE_BUFFER_GROWTH_FACTOR = Int2IntFunction.add(Byte.SIZE); sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java 211: Buffer buffer = new ByteArrayBuffer(message.available() + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java 458: Buffer response = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_FAILURE, remaining.length() + Byte.SIZE); 484: StringBuilder sb = new StringBuilder((authMethods.size() + 1) * Byte.SIZE); 502: buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_FAILURE, remaining.length() + Byte.SIZE); 540: welcomeBanner.length() + GenericUtils.length(lang) + Long.SIZE); sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java 318: Buffer response = createBuffer(SshConstants.SSH_MSG_USERAUTH_SUCCESS, Byte.SIZE); sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentProxy.java 219: Buffer buffer = new ByteArrayBuffer((extraLen <= 0) ? ByteArrayBuffer.DEFAULT_SIZE : extraLen + Byte.SIZE, false); sshd-core/src/main/java/org/apache/sshd/agent/common/AbstractAgentClient.java 139: Buffer sig = new ByteArrayBuffer(keyType.length() + signature.length + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java 78: public static final IntUnaryOperator RESPONSE_BUFFER_GROWTH_FACTOR = Int2IntFunction.add(Byte.SIZE); 623: Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_CHANNEL_CLOSE, Short.SIZE); 955: Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_CHANNEL_EOF, Short.SIZE); 1024: Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_CHANNEL_WINDOW_ADJUST, Short.SIZE); sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java 299: Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, remoteHost.length() + Long.SIZE); 365: Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_GLOBAL_REQUEST, remoteHost.length() + Long.SIZE); 1131: Buffer buffer = new ByteArrayBuffer(message.available() + Long.SIZE, false); sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java 148: type.length() + srcHost.length() + dstHost.length() + Long.SIZE); sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java 69: Buffer buffer = new ByteArrayBuffer(message.available() + Long.SIZE, false); 120: return (getUByte(buffer) << Byte.SIZE) + getUByte(buffer); 165: Buffer buffer = new ByteArrayBuffer(Long.SIZE, false); 223: buffer = new ByteArrayBuffer(Byte.SIZE, false); sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java 433: Buffer buffer = createBuffer(SshConstants.SSH_MSG_UNIMPLEMENTED, Byte.SIZE); 468: text.length() + lang.length() + Integer.SIZE /* a few extras */); 552: Buffer buffer = createBuffer(SshConstants.SSH_MSG_IGNORE, data.length + Byte.SIZE); 1051: Buffer nb = new ByteArrayBuffer(buffer.available() + Long.SIZE, false); 1064: Buffer buffer = createBuffer(SshConstants.SSH_MSG_DISCONNECT, msg.length() + Short.SIZE); sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java 539: Buffer buffer = createBuffer(SshConstants.SSH_MSG_NEWKEYS, Byte.SIZE); 634: SshConstants.SSH_MSG_SERVICE_ACCEPT, Byte.SIZE + GenericUtils.length(serviceName)); 921: ignoreBuf = createBuffer(SshConstants.SSH_MSG_IGNORE, ignoreDataLen + Byte.SIZE); 1117: return prepareBuffer(cmd, new ByteArrayBuffer(new byte[len + Byte.SIZE], false)); 1677: long recommendedByteRekeyBlocks = 1L << Math.min((avgCipherBlockSize * Byte.SIZE) / 4, 63); // in case sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java 94: public static final IntUnaryOperator RESPONSE_BUFFER_GROWTH_FACTOR = Int2IntFunction.add(Byte.SIZE); 239: SshConstants.SSH_MSG_IGNORE, DEFAULT_SESSION_IGNORE_HEARTBEAT_STRING.length() + Byte.SIZE); 790: Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_CONFIRMATION, Integer.SIZE); 811: Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, message.length() + Long.SIZE); 835: Long.SIZE + GenericUtils.length(message) + GenericUtils.length(lang)); sshd-core/src/main/java/org/apache/sshd/client/auth/password/UserAuthPassword.java 79: + Integer.SIZE /* 184: + Long.SIZE); sshd-core/src/main/java/org/apache/sshd/client/auth/hostbased/UserAuthHostBased.java 138: + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE); 181: + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE, sshd-core/src/main/java/org/apache/sshd/client/auth/pubkey/UserAuthPublicKey.java 203: + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE); 222: + algo.length() + ByteArrayBuffer.DEFAULT_SIZE + Long.SIZE, sshd-core/src/main/java/org/apache/sshd/client/auth/keyboard/UserAuthKeyboardInteractive.java 118: + Long.SIZE /* 204: SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE, numResponses * Long.SIZE + Byte.SIZE); sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java 113: Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST, Integer.SIZE); 154: SshConstants.SSH_MSG_KEX_DH_GEX_INIT, e.length + Byte.SIZE); sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java 103: Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEXDH_INIT, e.length + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelDirectTcpip.java 85: type.length() + remoteName.length() + localName.length() + Long.SIZE); sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelExec.java 63: Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, command.length() + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java 238: Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE); 260: SshConstants.SSH_MSG_CHANNEL_REQUEST, Long.SIZE); 285: Buffer modes = new ByteArrayBuffer(numModes * (1 + Integer.BYTES) + Long.SIZE, false); 308: SshConstants.SSH_MSG_CHANNEL_REQUEST, key.length() + GenericUtils.length(str) + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelShell.java 59: Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_REQUEST, Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSubsystem.java 83: Channel.CHANNEL_SUBSYSTEM.length() + systemName.length() + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java 164: username.length() + service.length() + Integer.SIZE); sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java 214: Buffer request = createBuffer(SshConstants.SSH_MSG_SERVICE_REQUEST, serviceName.length() + Byte.SIZE); sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java 125: SshConstants.SSH_MSG_GLOBAL_REQUEST, heartbeatRequest.length() + Byte.SIZE); {code} > Removing meaningless usage of Byte.SIZE, Integer.SIZE and Long.SIZE > ------------------------------------------------------------------- > > Key: SSHD-1010 > URL: https://issues.apache.org/jira/browse/SSHD-1010 > Project: MINA SSHD > Issue Type: Task > Reporter: Guillaume Nodet > Priority: Minor > > See > https://github.com/apache/mina-sshd/commit/a029229309d88215a1f7fb6e3edb7fe4feff1385 > There are lots of usage of {{xxx.SIZE}} when they usually refer to > {{xxx.BYTES}} in order to reserve a number of bytes in a buffer, or to refer > to a given value such as {{32}} which isn't related to a number of bits. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org