You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2015/07/16 15:37:12 UTC
[5/6] mina-sshd git commit: Remove boxing / unboxing,
remove useless final modifiers, use try with resources, fix a few javadocs
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
index 95641fa..8ff7f36 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java
@@ -145,35 +145,35 @@ public class SshConfigFileReader {
public static final SyslogFacilityValue DEFAULT_SYSLOG_FACILITY=SyslogFacilityValue.AUTH;
public static final String SUBSYSTEM_CONFIG_PROP="Subsystem";
- public static final Properties readConfigFile(File file) throws IOException {
+ public static Properties readConfigFile(File file) throws IOException {
return readConfigFile(file.toPath(), IoUtils.EMPTY_OPEN_OPTIONS);
}
- public static final Properties readConfigFile(Path path, OpenOption ... options) throws IOException {
+ public static Properties readConfigFile(Path path, OpenOption ... options) throws IOException {
try(InputStream input = Files.newInputStream(path, options)) {
return readConfigFile(input, true);
}
}
- public static final Properties readConfigFile(URL url) throws IOException {
+ public static Properties readConfigFile(URL url) throws IOException {
try(InputStream input=url.openStream()) {
return readConfigFile(input, true);
}
}
- public static final Properties readConfigFile(String path) throws IOException {
+ public static Properties readConfigFile(String path) throws IOException {
try(InputStream input=new FileInputStream(path)) {
return readConfigFile(input, true);
}
}
- public static final Properties readConfigFile(InputStream input, boolean okToClose) throws IOException {
+ public static Properties readConfigFile(InputStream input, boolean okToClose) throws IOException {
try(Reader reader=new InputStreamReader(NoCloseInputStream.resolveInputStream(input, okToClose), StandardCharsets.UTF_8)) {
return readConfigFile(reader, true);
}
}
- public static final Properties readConfigFile(Reader reader, boolean okToClose) throws IOException {
+ public static Properties readConfigFile(Reader reader, boolean okToClose) throws IOException {
try(BufferedReader buf=new BufferedReader(NoCloseReader.resolveReader(reader, okToClose))) {
return readConfigFile(buf);
}
@@ -188,7 +188,7 @@ public class SshConfigFileReader {
* @return The read properties
* @throws IOException If failed to read or malformed content
*/
- public static final Properties readConfigFile(BufferedReader rdr) throws IOException {
+ public static Properties readConfigFile(BufferedReader rdr) throws IOException {
Properties props=new Properties();
int lineNumber=1;
for (String line=rdr.readLine(); line != null; line=rdr.readLine(), lineNumber++) {
@@ -241,7 +241,7 @@ public class SshConfigFileReader {
* @return The resolved property
* @throws NumberFormatException if malformed value
*/
- public static final long getLongProperty(Properties props, String name, long defaultValue) {
+ public static long getLongProperty(Properties props, String name, long defaultValue) {
String value = (props == null) ? null : props.getProperty(name);
if (GenericUtils.isEmpty(value)) {
return defaultValue;
@@ -257,7 +257,7 @@ public class SshConfigFileReader {
* empty string
* @throws NumberFormatException if malformed value
*/
- public static final Long getLong(Properties props, String name) {
+ public static Long getLong(Properties props, String name) {
String value = (props == null) ? null : props.getProperty(name);
if (GenericUtils.isEmpty(value)) {
return null;
@@ -274,7 +274,7 @@ public class SshConfigFileReader {
* @return The resolved property
* @throws NumberFormatException if malformed value
*/
- public static final int getIntProperty(Properties props, String name, int defaultValue) {
+ public static int getIntProperty(Properties props, String name, int defaultValue) {
String value = (props == null) ? null : props.getProperty(name);
if (GenericUtils.isEmpty(value)) {
return defaultValue;
@@ -290,7 +290,7 @@ public class SshConfigFileReader {
* empty string
* @throws NumberFormatException if malformed value
*/
- public static final Integer getInteger(Properties props, String name) {
+ public static Integer getInteger(Properties props, String name) {
String value = (props == null) ? null : props.getProperty(name);
if (GenericUtils.isEmpty(value)) {
return null;
@@ -307,7 +307,7 @@ public class SshConfigFileReader {
* @return The resolved property
* @throws NumberFormatException if malformed value
*/
- public static final boolean getBooleanProperty(Properties props, String name, boolean defaultValue) {
+ public static boolean getBooleanProperty(Properties props, String name, boolean defaultValue) {
String value = (props == null) ? null : props.getProperty(name);
if (GenericUtils.isEmpty(value)) {
return defaultValue;
@@ -323,12 +323,12 @@ public class SshConfigFileReader {
* empty string
* @throws NumberFormatException if malformed value
*/
- public static final Boolean getBoolean(Properties props, String name) {
+ public static Boolean getBoolean(Properties props, String name) {
String value = (props == null) ? null : props.getProperty(name);
if (GenericUtils.isEmpty(value)) {
return null;
} else {
- return Boolean.valueOf(parseBooleanValue(value));
+ return parseBooleanValue(value);
}
}
@@ -339,7 +339,7 @@ public class SshConfigFileReader {
* input string
* @return The result
*/
- public static final boolean parseBooleanValue(String v, boolean defaultValue) {
+ public static boolean parseBooleanValue(String v, boolean defaultValue) {
if (GenericUtils.isEmpty(v)) {
return defaultValue;
} else {
@@ -353,7 +353,7 @@ public class SshConfigFileReader {
* @return The result - <B>Note:</B> {@code null}/empty values are
* intrepreted as {@code false}
*/
- public static final boolean parseBooleanValue(String v) {
+ public static boolean parseBooleanValue(String v) {
if ("yes".equalsIgnoreCase(v)
|| "y".equalsIgnoreCase(v)
|| "on".equalsIgnoreCase(v)
@@ -366,7 +366,7 @@ public class SshConfigFileReader {
/**
* @param props The {@link Properties} - ignored if {@code null}/empty
- * @return A {@BuiltinCiphers.ParseResult} of all the {@link NamedFactory}-ies
+ * @return A {@link BuiltinCiphers.ParseResult} of all the {@link NamedFactory}-ies
* whose name appears in the string and represent a built-in cipher.
* Any unknown name is <U>ignored</U>. The order of the returned result
* is the same as the original order - bar the unknown ciphers.
@@ -375,7 +375,7 @@ public class SshConfigFileReader {
* @see #CIPHERS_CONFIG_PROP
* @see BuiltinCiphers#parseCiphersList(String)
*/
- public static final BuiltinCiphers.ParseResult getCiphers(Properties props) {
+ public static BuiltinCiphers.ParseResult getCiphers(Properties props) {
return BuiltinCiphers.parseCiphersList((props == null) ? null : props.getProperty(CIPHERS_CONFIG_PROP));
}
@@ -390,7 +390,7 @@ public class SshConfigFileReader {
* @see #MACS_CONFIG_PROP
* @see BuiltinMacs#parseMacsList(String)
*/
- public static final BuiltinMacs.ParseResult getMacs(Properties props) {
+ public static BuiltinMacs.ParseResult getMacs(Properties props) {
return BuiltinMacs.parseMacsList((props == null) ? null : props.getProperty(MACS_CONFIG_PROP));
}
@@ -404,7 +404,7 @@ public class SshConfigFileReader {
* @see #HOST_KEY_ALGORITHMS_CONFIG_PROP
* @see BuiltinSignatures#parseSignatureList(String)
*/
- public static final BuiltinSignatures.ParseResult getSignatures(Properties props) {
+ public static BuiltinSignatures.ParseResult getSignatures(Properties props) {
return BuiltinSignatures.parseSignatureList((props == null) ? null : props.getProperty(HOST_KEY_ALGORITHMS_CONFIG_PROP));
}
@@ -418,7 +418,7 @@ public class SshConfigFileReader {
* @see #KEX_ALGORITHMS_CONFIG_PROP
* @see BuiltinDHFactories#parseDHFactoriesList(String)
*/
- public static final BuiltinDHFactories.ParseResult getKexFactories(Properties props) {
+ public static BuiltinDHFactories.ParseResult getKexFactories(Properties props) {
return BuiltinDHFactories.parseDHFactoriesList((props == null) ? null : props.getProperty(KEX_ALGORITHMS_CONFIG_PROP));
}
@@ -427,17 +427,17 @@ public class SshConfigFileReader {
* @return The matching {@link NamedFactory} for the configured value.
* {@code null} if no configuration or unknown name specified
*/
- public static final CompressionFactory getCompression(Properties props) {
+ public static CompressionFactory getCompression(Properties props) {
return CompressionConfigValue.fromName((props == null) ? null : props.getProperty(COMPRESSION_PROP));
}
- public static final <S extends SshServer> S configure(S server, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ public static <S extends SshServer> S configure(S server, Properties props, boolean lenient, boolean ignoreUnsupported) {
configure((AbstractFactoryManager) server, props, lenient, ignoreUnsupported);
configureKeyExchanges(server, props, lenient, ServerBuilder.DH2KEX, ignoreUnsupported);
return server;
}
- public static final <C extends SshClient> C configure(C client, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ public static <C extends SshClient> C configure(C client, Properties props, boolean lenient, boolean ignoreUnsupported) {
configure((AbstractFactoryManager) client, props, lenient, ignoreUnsupported);
configureKeyExchanges(client, props, lenient, ClientBuilder.DH2KEX, ignoreUnsupported);
return client;
@@ -463,7 +463,7 @@ public class SshConfigFileReader {
* or unsupported values there is an empty configuration exception is thrown
* @return The configured manager
*/
- public static final <M extends AbstractFactoryManager> M configure(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ public static <M extends AbstractFactoryManager> M configure(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
configureCiphers(manager, props, lenient, ignoreUnsupported);
configureSignatures(manager, props, lenient, ignoreUnsupported);
configureMacs(manager, props, lenient, ignoreUnsupported);
@@ -472,13 +472,13 @@ public class SshConfigFileReader {
return manager;
}
- public static final <M extends AbstractFactoryManager> M configureCiphers(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(props, "No properties to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureCiphers(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(props, "No properties to configure");
return configureCiphers(manager, props.getProperty(CIPHERS_CONFIG_PROP, DEFAULT_CIPHERS), lenient, ignoreUnsupported);
}
- public static final <M extends AbstractFactoryManager> M configureCiphers(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(manager, "No manager to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureCiphers(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(manager, "No manager to configure");
BuiltinCiphers.ParseResult result=BuiltinCiphers.parseCiphersList(value);
Collection<String> unsupported=result.getUnsupportedFactories();
@@ -490,13 +490,13 @@ public class SshConfigFileReader {
return manager;
}
- public static final <M extends AbstractFactoryManager> M configureSignatures(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(props, "No properties to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureSignatures(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(props, "No properties to configure");
return configureSignatures(manager, props.getProperty(HOST_KEY_ALGORITHMS_CONFIG_PROP, DEFAULT_HOST_KEY_ALGORITHMS), lenient, ignoreUnsupported);
}
- public static final <M extends AbstractFactoryManager> M configureSignatures(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(manager, "No manager to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureSignatures(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(manager, "No manager to configure");
BuiltinSignatures.ParseResult result=BuiltinSignatures.parseSignatureList(value);
Collection<String> unsupported=result.getUnsupportedFactories();
@@ -508,13 +508,13 @@ public class SshConfigFileReader {
return manager;
}
- public static final <M extends AbstractFactoryManager> M configureMacs(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(props, "No properties to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureMacs(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(props, "No properties to configure");
return configureMacs(manager, props.getProperty(MACS_CONFIG_PROP, DEFAULT_MACS), lenient, ignoreUnsupported);
}
- public static final <M extends AbstractFactoryManager> M configureMacs(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(manager, "No manager to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureMacs(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(manager, "No manager to configure");
BuiltinMacs.ParseResult result=BuiltinMacs.parseMacsList(value);
Collection<String> unsupported=result.getUnsupportedFactories();
@@ -540,16 +540,16 @@ public class SshConfigFileReader {
* @see #KEX_ALGORITHMS_CONFIG_PROP
* @see #DEFAULT_KEX_ALGORITHMS
*/
- public static final <M extends AbstractFactoryManager> M configureKeyExchanges(
+ public static <M extends AbstractFactoryManager> M configureKeyExchanges(
M manager, Properties props, boolean lenient, Transformer<? super DHFactory, ? extends NamedFactory<KeyExchange>> xformer, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(props, "No properties to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ ValidateUtils.checkNotNull(props, "No properties to configure");
return configureKeyExchanges(manager, props.getProperty(KEX_ALGORITHMS_CONFIG_PROP, DEFAULT_KEX_ALGORITHMS), lenient, xformer, ignoreUnsupported);
}
- public static final <M extends AbstractFactoryManager> M configureKeyExchanges(
+ public static <M extends AbstractFactoryManager> M configureKeyExchanges(
M manager, String value, boolean lenient, Transformer<? super DHFactory, ? extends NamedFactory<KeyExchange>> xformer, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(manager, "No manager to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
- ValidateUtils.checkNotNull(xformer, "No DHFactory transformer", GenericUtils.EMPTY_OBJECT_ARRAY);
+ ValidateUtils.checkNotNull(manager, "No manager to configure");
+ ValidateUtils.checkNotNull(xformer, "No DHFactory transformer");
BuiltinDHFactories.ParseResult result=BuiltinDHFactories.parseDHFactoriesList(value);
Collection<String> unsupported=result.getUnsupportedFactories();
@@ -572,9 +572,9 @@ public class SshConfigFileReader {
* @return The configured manager - <B>Note:</B> if the result of filtering due
* to lenient mode or ignored unsupported value is empty then no factories are set
*/
- public static final <M extends AbstractFactoryManager> M configureCompression(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(manager, "No manager to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
- ValidateUtils.checkNotNull(props, "No properties to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureCompression(M manager, Properties props, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(manager, "No manager to configure");
+ ValidateUtils.checkNotNull(props, "No properties to configure");
String value=props.getProperty(COMPRESSION_PROP, DEFAULT_COMPRESSION);
CompressionFactory factory=CompressionConfigValue.fromName(value);
@@ -587,8 +587,8 @@ public class SshConfigFileReader {
}
// accepts BOTH CompressionConfigValue(s) and/or BuiltinCompressions - including extensions
- public static final <M extends AbstractFactoryManager> M configureCompression(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
- ValidateUtils.checkNotNull(manager, "No manager to configure", GenericUtils.EMPTY_OBJECT_ARRAY);
+ public static <M extends AbstractFactoryManager> M configureCompression(M manager, String value, boolean lenient, boolean ignoreUnsupported) {
+ ValidateUtils.checkNotNull(manager, "No manager to configure");
CompressionFactory factory=CompressionConfigValue.fromName(value);
if (factory != null) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java b/sshd-core/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
index 7ae4b36..680ef61 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
@@ -34,7 +34,8 @@ public enum SyslogFacilityValue {
public static final Set<SyslogFacilityValue> VALUES=
Collections.unmodifiableSet(EnumSet.allOf(SyslogFacilityValue.class));
- public static final SyslogFacilityValue fromName(String n) {
+
+ public static SyslogFacilityValue fromName(String n) {
if (GenericUtils.isEmpty(n)) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java b/sshd-core/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
index 6430325..41875cd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
@@ -61,7 +61,8 @@ public enum TimeValueConfig {
public static final Set<TimeValueConfig> VALUES=
Collections.unmodifiableSet(EnumSet.allOf(TimeValueConfig.class));
- public static final TimeValueConfig fromValueChar(char ch) {
+
+ public static TimeValueConfig fromValueChar(char ch) {
if ((ch <= ' ') || (ch >= 0x7F)) {
return null;
}
@@ -81,7 +82,7 @@ public enum TimeValueConfig {
* @see #parse(String)
* @see #durationOf(Map)
*/
- public static final long durationOf(String s) {
+ public static long durationOf(String s) {
Map<TimeValueConfig,Long> spec=parse(s);
return durationOf(spec);
}
@@ -93,7 +94,7 @@ public enum TimeValueConfig {
* @throws NumberFormatException If bad numbers found - e.g., negative counts
* @throws IllegalArgumentException If bad format - e.g., unknown unit
*/
- public static final Map<TimeValueConfig,Long> parse(String s) throws NumberFormatException, IllegalArgumentException {
+ public static Map<TimeValueConfig,Long> parse(String s) throws NumberFormatException, IllegalArgumentException {
if (GenericUtils.isEmpty(s)) {
return Collections.emptyMap();
}
@@ -116,8 +117,8 @@ public enum TimeValueConfig {
}
String v=s.substring(lastPos, curPos);
- Long count=Long.valueOf(v);
- if (count.longValue() < 0L) {
+ long count=Long.parseLong(v);
+ if (count < 0L) {
throw new IllegalArgumentException("parse(" + s + ") negative count (" + v + ") for " + c.name());
}
@@ -133,8 +134,8 @@ public enum TimeValueConfig {
if (lastPos < s.length()) {
String v=s.substring(lastPos);
- Long count=Long.valueOf(v);
- if (count.longValue() < 0L) {
+ long count=Long.parseLong(v);
+ if (count < 0L) {
throw new IllegalArgumentException("parse(" + s + ") negative count (" + v + ") for last component");
}
@@ -152,7 +153,7 @@ public enum TimeValueConfig {
* @return The total duration in milliseconds
* @throws IllegalArgumentException If negative count for a time unit
*/
- public static final long durationOf(Map<TimeValueConfig,? extends Number> spec) throws IllegalArgumentException {
+ public static long durationOf(Map<TimeValueConfig,? extends Number> spec) throws IllegalArgumentException {
if (GenericUtils.isEmpty(spec)) {
return (-1L);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/keys/AbstractPublicKeyEntryDecoder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/AbstractPublicKeyEntryDecoder.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/AbstractPublicKeyEntryDecoder.java
index 8c701a7..555bcc9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/AbstractPublicKeyEntryDecoder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/AbstractPublicKeyEntryDecoder.java
@@ -52,9 +52,9 @@ public abstract class AbstractPublicKeyEntryDecoder<PUB extends PublicKey,PRV ex
private final Collection<String> names;
protected AbstractPublicKeyEntryDecoder(Class<PUB> pubType, Class<PRV> prvType, Collection<String> names) {
- this.pubType = ValidateUtils.checkNotNull(pubType, "No public key type specified", GenericUtils.EMPTY_OBJECT_ARRAY);
- this.prvType = ValidateUtils.checkNotNull(prvType, "No private key type specified", GenericUtils.EMPTY_OBJECT_ARRAY);
- this.names = ValidateUtils.checkNotNullAndNotEmpty(names, "No type names provided", GenericUtils.EMPTY_OBJECT_ARRAY);
+ this.pubType = ValidateUtils.checkNotNull(pubType, "No public key type specified");
+ this.prvType = ValidateUtils.checkNotNull(prvType, "No private key type specified");
+ this.names = ValidateUtils.checkNotNullAndNotEmpty(names, "No type names provided");
}
@Override
@@ -175,33 +175,33 @@ public abstract class AbstractPublicKeyEntryDecoder<PUB extends PublicKey,PRV ex
return getPublicKeyType().getSimpleName() + ": " + getSupportedTypeNames();
}
- public static final int encodeString(OutputStream s, String v) throws IOException {
+ public static int encodeString(OutputStream s, String v) throws IOException {
return encodeString(s, v, StandardCharsets.UTF_8);
}
- public static final int encodeString(OutputStream s, String v, String charset) throws IOException {
+ public static int encodeString(OutputStream s, String v, String charset) throws IOException {
return encodeString(s, v, Charset.forName(charset));
}
- public static final int encodeString(OutputStream s, String v, Charset cs) throws IOException {
+ public static int encodeString(OutputStream s, String v, Charset cs) throws IOException {
return writeRLEBytes(s, v.getBytes(cs));
}
- public static final int encodeBigInt(OutputStream s, BigInteger v) throws IOException {
+ public static int encodeBigInt(OutputStream s, BigInteger v) throws IOException {
return writeRLEBytes(s, v.toByteArray());
}
- public static final int writeRLEBytes(OutputStream s, byte ... bytes) throws IOException {
+ public static int writeRLEBytes(OutputStream s, byte ... bytes) throws IOException {
return writeRLEBytes(s, bytes, 0, bytes.length);
}
- public static final int writeRLEBytes(OutputStream s, byte[] bytes, int off, int len) throws IOException {
+ public static int writeRLEBytes(OutputStream s, byte[] bytes, int off, int len) throws IOException {
byte[] lenBytes=encodeInt(s, len);
s.write(bytes, off, len);
return lenBytes.length + len;
}
- public static final byte[] encodeInt(OutputStream s, int v) throws IOException {
+ public static byte[] encodeInt(OutputStream s, int v) throws IOException {
byte[] bytes={
(byte) ((v >> 24) & 0xFF),
(byte) ((v >> 16) & 0xFF),
@@ -212,31 +212,31 @@ public abstract class AbstractPublicKeyEntryDecoder<PUB extends PublicKey,PRV ex
return bytes;
}
- public static final String decodeString(InputStream s) throws IOException {
+ public static String decodeString(InputStream s) throws IOException {
return decodeString(s, StandardCharsets.UTF_8);
}
- public static final String decodeString(InputStream s, String charset) throws IOException {
+ public static String decodeString(InputStream s, String charset) throws IOException {
return decodeString(s, Charset.forName(charset));
}
- public static final String decodeString(InputStream s, Charset cs) throws IOException {
+ public static String decodeString(InputStream s, Charset cs) throws IOException {
byte[] bytes=readRLEBytes(s);
return new String(bytes, cs);
}
- public static final BigInteger decodeBigInt(InputStream s) throws IOException {
+ public static BigInteger decodeBigInt(InputStream s) throws IOException {
return new BigInteger(readRLEBytes(s));
}
- public static final byte[] readRLEBytes(InputStream s) throws IOException {
+ public static byte[] readRLEBytes(InputStream s) throws IOException {
int len=decodeInt(s);
byte[] bytes=new byte[len];
IoUtils.readFully(s, bytes);
return bytes;
}
- public static final int decodeInt(InputStream s) throws IOException {
+ public static int decodeInt(InputStream s) throws IOException {
byte[] bytes={ 0, 0, 0, 0 };
IoUtils.readFully(s, bytes);
return ((bytes[0] & 0xFF) << 24)
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
index 1755f31..167d004 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
@@ -109,7 +109,7 @@ public enum BuiltinIdentities implements Identity {
* @return The matching {@link BuiltinIdentities} whose {@link #getName()}
* value matches case <U>insensitive</U> or {@code null} if no match found
*/
- public static final BuiltinIdentities fromName(String name) {
+ public static BuiltinIdentities fromName(String name) {
return NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
@@ -118,7 +118,7 @@ public enum BuiltinIdentities implements Identity {
* @return The matching {@link BuiltinIdentities} whose {@link #getAlgorithm()}
* value matches case <U>insensitive</U> or {@code null} if no match found
*/
- public static final BuiltinIdentities fromAlgorithm(String algorithm) {
+ public static BuiltinIdentities fromAlgorithm(String algorithm) {
if (GenericUtils.isEmpty(algorithm)) {
return null;
}
@@ -139,7 +139,7 @@ public enum BuiltinIdentities implements Identity {
* match could be found
* @see #fromKey(Key)
*/
- public static final BuiltinIdentities fromKeyPair(KeyPair kp) {
+ public static BuiltinIdentities fromKeyPair(KeyPair kp) {
if (kp == null) {
return null;
}
@@ -159,7 +159,7 @@ public enum BuiltinIdentities implements Identity {
* private key type matches the requested one or {@code null} if no match found
* @see #fromKeyType(Class)
*/
- public static final BuiltinIdentities fromKey(Key key) {
+ public static BuiltinIdentities fromKey(Key key) {
return fromKeyType((key == null) ? null : key.getClass());
}
@@ -171,7 +171,7 @@ public enum BuiltinIdentities implements Identity {
* @see #getPublicKeyType()
* @see #getPrivateKeyType()
*/
- public static final BuiltinIdentities fromKeyType(Class<?> clazz) {
+ public static BuiltinIdentities fromKeyType(Class<?> clazz) {
if ((clazz == null) || (!Key.class.isAssignableFrom(clazz))) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/keys/ECDSAPublicKeyEntryDecoder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/ECDSAPublicKeyEntryDecoder.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/ECDSAPublicKeyEntryDecoder.java
index a539fce..dd499f8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/ECDSAPublicKeyEntryDecoder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/ECDSAPublicKeyEntryDecoder.java
@@ -132,10 +132,10 @@ public class ECDSAPublicKeyEntryDecoder extends AbstractPublicKeyEntryDecoder<EC
@Override
public String encodePublicKey(OutputStream s, ECPublicKey key) throws IOException {
- ValidateUtils.checkNotNull(key, "No public key provided", GenericUtils.EMPTY_OBJECT_ARRAY);
+ ValidateUtils.checkNotNull(key, "No public key provided");
- ECParameterSpec params = ValidateUtils.checkNotNull(key.getParams(), "No EC parameters available", GenericUtils.EMPTY_OBJECT_ARRAY);
- ECCurves curve = ValidateUtils.checkNotNull(ECCurves.fromCurveParameters(params), "Cannot determine curve", GenericUtils.EMPTY_OBJECT_ARRAY);
+ ECParameterSpec params = ValidateUtils.checkNotNull(key.getParams(), "No EC parameters available");
+ ECCurves curve = ValidateUtils.checkNotNull(ECCurves.fromCurveParameters(params), "Cannot determine curve");
String keyType = curve.getKeyType(), curveName = curve.getName();
encodeString(s, keyType);
// see rfc5656 section 3.1
@@ -336,7 +336,8 @@ public class ECDSAPublicKeyEntryDecoder extends AbstractPublicKeyEntryDecoder<EC
public static final Set<ECPointCompression> VALUES=
Collections.unmodifiableSet(EnumSet.allOf(ECPointCompression.class));
- public static final ECPointCompression fromIndicatorValue(int value) {
+
+ public static ECPointCompression fromIndicatorValue(int value) {
if ((value < 0) || (value > 0xFF)) {
return null; // must be a byte value
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
index e1b945f..062446b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/IdentityUtils.java
@@ -54,11 +54,8 @@ public final class IdentityUtils {
if (GenericUtils.isEmpty(type)) {
return null;
} else {
- return new StringBuilder(GenericUtils.length(prefix) + type.length() + GenericUtils.length(suffix))
- .append(GenericUtils.trimToEmpty(prefix))
- .append(type.toLowerCase())
- .append(GenericUtils.trimToEmpty(suffix))
- .toString();
+ return GenericUtils.trimToEmpty(prefix)
+ + type.toLowerCase() + GenericUtils.trimToEmpty(suffix);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
index cd3ec94..a7c07de 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/PublicKeyEntry.java
@@ -226,7 +226,7 @@ public class PublicKeyEntry implements Serializable {
* @return The updated appendable instance
* @throws IOException If failed to append the data
*/
- public static final <A extends Appendable> A appendPublicKeyEntry(A sb, PublicKey key) throws IOException {
+ public static <A extends Appendable> A appendPublicKeyEntry(A sb, PublicKey key) throws IOException {
@SuppressWarnings("unchecked")
PublicKeyEntryDecoder<PublicKey,?> decoder = (PublicKeyEntryDecoder<PublicKey,?>) KeyUtils.getPublicKeyEntryDecoder(key);
if (decoder == null) {
@@ -263,7 +263,7 @@ public class PublicKeyEntry implements Serializable {
* {@code known_hosts}, {@code authorized_keys}, etc.
*/
@SuppressWarnings("synthetic-access")
- public static final File getDefaultKeysFolder() {
+ public static File getDefaultKeysFolder() {
return LazyDefaultKeysFolderHolder.folder;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java b/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
index b3a7bf4..9412161 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
@@ -28,7 +28,7 @@ public interface FileSystemAware {
/**
* Set the file system in which this shell will be executed.
*
- * @param fileSystem
+ * @param fileSystem the file system
*/
void setFileSystem(FileSystem fileSystem);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
index 6b27d5a..8af95ad 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultTcpipForwarder.java
@@ -65,10 +65,10 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
}
};
private final Session session;
- private final Map<Integer, SshdSocketAddress> localToRemote = new HashMap<Integer, SshdSocketAddress>();
- private final Map<Integer, SshdSocketAddress> remoteToLocal = new HashMap<Integer, SshdSocketAddress>();
- private final Map<Integer, SocksProxy> dynamicLocal = new HashMap<Integer, SocksProxy>();
- private final Set<LocalForwardingEntry> localForwards = new HashSet<LocalForwardingEntry>();
+ private final Map<Integer, SshdSocketAddress> localToRemote = new HashMap<>();
+ private final Map<Integer, SshdSocketAddress> remoteToLocal = new HashMap<>();
+ private final Map<Integer, SocksProxy> dynamicLocal = new HashMap<>();
+ private final Set<LocalForwardingEntry> localForwards = new HashSet<>();
private final IoHandlerFactory staticIoHandlerFactory = new IoHandlerFactory() {
@Override
public IoHandler create() {
@@ -107,7 +107,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
int port = bound.getPort();
SshdSocketAddress prev;
synchronized(localToRemote) {
- prev = localToRemote.put(Integer.valueOf(port), remote);
+ prev = localToRemote.put(port, remote);
}
if (prev != null) {
@@ -127,7 +127,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
SshdSocketAddress bound;
synchronized(localToRemote) {
- bound = localToRemote.remove(Integer.valueOf(local.getPort()));
+ bound = localToRemote.remove(local.getPort());
}
if ((bound != null) && (acceptor != null)) {
@@ -160,7 +160,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
// TODO: Is it really safe to only store the local address after the request ?
SshdSocketAddress prev;
synchronized(remoteToLocal) {
- prev = remoteToLocal.put(Integer.valueOf(port), local);
+ prev = remoteToLocal.put(port, local);
}
if (prev != null) {
@@ -179,7 +179,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
public synchronized void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException {
SshdSocketAddress bound;
synchronized(remoteToLocal) {
- bound = remoteToLocal.remove(Integer.valueOf(remote.getPort()));
+ bound = remoteToLocal.remove(remote.getPort());
}
if (bound != null) {
@@ -216,7 +216,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
InetSocketAddress bound = doBind(local, socksProxyIoHandlerFactory);
int port = bound.getPort();
synchronized(dynamicLocal) {
- prev = dynamicLocal.put(Integer.valueOf(port), socksProxy);
+ prev = dynamicLocal.put(port, socksProxy);
}
if (prev != null) {
@@ -235,7 +235,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
public synchronized void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException {
Closeable obj;
synchronized(dynamicLocal) {
- obj = dynamicLocal.remove(Integer.valueOf(local.getPort()));
+ obj = dynamicLocal.remove(local.getPort());
}
if (obj != null) {
@@ -254,7 +254,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
@Override
public synchronized SshdSocketAddress getForwardedPort(int remotePort) {
synchronized(remoteToLocal) {
- return remoteToLocal.get(Integer.valueOf(remotePort));
+ return remoteToLocal.get(remotePort);
}
}
@@ -375,7 +375,7 @@ public class DefaultTcpipForwarder extends CloseableUtils.AbstractInnerCloseable
public void sessionCreated(final IoSession session) throws Exception {
InetSocketAddress local = (InetSocketAddress) session.getLocalAddress();
int localPort = local.getPort();
- SshdSocketAddress remote = localToRemote.get(Integer.valueOf(localPort));
+ SshdSocketAddress remote = localToRemote.get(localPort);
final TcpipClientChannel channel;
if (remote != null) {
channel = new TcpipClientChannel(TcpipClientChannel.Type.Direct, session, remote);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
index cb70913..c0d6a7c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/SocksProxy.java
@@ -147,7 +147,7 @@ public class SocksProxy extends CloseableUtils.AbstractCloseable implements IoHa
host = getNTString(buffer);
}
if (log.isDebugEnabled()) {
- log.debug("Received socks4 connection request for {} to {}:{}", userId, host, Integer.valueOf(port));
+ log.debug("Received socks4 connection request for {} to {}:{}", userId, host, port);
}
SshdSocketAddress remote = new SshdSocketAddress(host, port);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultCloseFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultCloseFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultCloseFuture.java
index 2f64ca9..3f0da11 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultCloseFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/future/DefaultCloseFuture.java
@@ -35,7 +35,7 @@ public class DefaultCloseFuture extends DefaultSshFuture<CloseFuture> implements
@Override // TODO for JDK-8 make this a default method
public boolean isClosed() {
if (isDone()) {
- return ((Boolean) getValue()).booleanValue();
+ return (Boolean) getValue();
} else {
return false;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
index b67b1ff..4dd1c7b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/AbstractIoWriteFuture.java
@@ -46,7 +46,7 @@ public abstract class AbstractIoWriteFuture extends DefaultSshFuture<IoWriteFutu
@Override // TODO for JDK-8 make this a default method
public void verify(long timeout) throws IOException {
Boolean result = verifyResult(Boolean.class, timeout);
- if (!result.booleanValue()) {
+ if (!result) {
throw new SshException("Write failed signalled");
}
}
@@ -54,7 +54,7 @@ public abstract class AbstractIoWriteFuture extends DefaultSshFuture<IoWriteFutu
@Override // TODO for JDK-8 make this a default method
public boolean isWritten() {
Object value = getValue();
- return (value instanceof Boolean) && ((Boolean) value).booleanValue();
+ return (value instanceof Boolean) && (Boolean) value;
}
@Override // TODO for JDK-8 make this a default method
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
index f5c558e..da71b02 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
@@ -66,11 +66,11 @@ public enum BuiltinIoServiceFactoryFactories implements NamedFactory<IoServiceFa
public static final Set<BuiltinIoServiceFactoryFactories> VALUES =
Collections.unmodifiableSet(EnumSet.allOf(BuiltinIoServiceFactoryFactories.class));
- public static final BuiltinIoServiceFactoryFactories fromFactoryName(String name) {
+ public static BuiltinIoServiceFactoryFactories fromFactoryName(String name) {
return NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
- public static final BuiltinIoServiceFactoryFactories fromFactoryClass(Class<?> clazz) {
+ public static BuiltinIoServiceFactoryFactories fromFactoryClass(Class<?> clazz) {
if ((clazz == null) || (!IoServiceFactoryFactory.class.isAssignableFrom(clazz))) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
index 2053797..360c501 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/mina/MinaService.java
@@ -126,19 +126,19 @@ public abstract class MinaService extends CloseableUtils.AbstractCloseable imple
Integer intVal;
Boolean boolVal;
if ((boolVal = getBoolean(FactoryManager.SOCKET_KEEPALIVE)) != null) {
- config.setKeepAlive(boolVal.booleanValue());
+ config.setKeepAlive(boolVal);
}
if ((intVal = getInteger(FactoryManager.SOCKET_SNDBUF)) != null) {
- config.setSendBufferSize(intVal.intValue());
+ config.setSendBufferSize(intVal);
}
if ((intVal = getInteger(FactoryManager.SOCKET_RCVBUF)) != null) {
- config.setReceiveBufferSize(intVal.intValue());
+ config.setReceiveBufferSize(intVal);
}
if ((intVal = getInteger(FactoryManager.SOCKET_LINGER)) != null) {
- config.setSoLinger(intVal.intValue());
+ config.setSoLinger(intVal);
}
if ((boolVal = getBoolean(FactoryManager.SOCKET_LINGER)) != null) {
- config.setTcpNoDelay(boolVal.booleanValue());
+ config.setTcpNoDelay(boolVal);
}
if (sessionConfig != null) {
config.setAll(sessionConfig);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
index aaa83f8..5f8e071 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Acceptor.java
@@ -143,7 +143,7 @@ public class Nio2Acceptor extends Nio2Service implements IoAcceptor {
// Create a session
session = new Nio2Session(Nio2Acceptor.this, manager, handler, result);
handler.sessionCreated(session);
- sessions.put(Long.valueOf(session.getId()), session);
+ sessions.put(session.getId(), session);
session.startReading();
} catch (Throwable exc) {
failed(exc, address);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
index 722f9f5..b809689 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Connector.java
@@ -57,7 +57,7 @@ public class Nio2Connector extends Nio2Service implements IoConnector {
try {
Nio2Session session = new Nio2Session(Nio2Connector.this, manager, handler, socket);
handler.sessionCreated(session);
- sessions.put(Long.valueOf(session.getId()), session);
+ sessions.put(session.getId(), session);
future.setSession(session);
session.startReading();
} catch (Throwable e) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
index 69aaacb..bb7ae2f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Service.java
@@ -73,7 +73,7 @@ public abstract class Nio2Service extends CloseableUtils.AbstractInnerCloseable
}
public void sessionClosed(Nio2Session session) {
- sessions.remove(Long.valueOf(session.getId()));
+ sessions.remove(session.getId());
}
protected <T> void setOption(NetworkChannel socket, String property, SocketOption<T> option, T defaultValue) throws IOException {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
index a932072..b53411f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/nio2/Nio2Session.java
@@ -213,7 +213,7 @@ public class Nio2Session extends CloseableUtils.AbstractCloseable implements IoS
@SuppressWarnings("synthetic-access")
protected void onCompleted(Integer result, Object attachment) {
try {
- if (result.intValue() >= 0) {
+ if (result >= 0) {
log.debug("Read {} bytes", result);
buffer.flip();
handler.messageReceived(Nio2Session.this, bufReader);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
index 0ea2ab2..4f9c5c7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
@@ -181,7 +181,7 @@ public enum BuiltinDHFactories implements DHFactory {
* or overrides a built-in one or overrides another registered factory
* with the same name (case <U>insensitive</U>).
*/
- public static final void registerExtension(DHFactory extension) {
+ public static void registerExtension(DHFactory extension) {
String name=ValidateUtils.checkNotNull(extension, "No extension provided").getName();
ValidateUtils.checkTrue(fromFactoryName(name) == null, "Extension overrides built-in: %s", name);
@@ -195,7 +195,7 @@ public enum BuiltinDHFactories implements DHFactory {
* @return A {@link SortedSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static final SortedSet<DHFactory> getRegisteredExtensions() {
+ public static SortedSet<DHFactory> getRegisteredExtensions() {
// TODO for JDK-8 return Collections.emptySortedSet()
synchronized(extensions) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, extensions.values());
@@ -207,7 +207,7 @@ public enum BuiltinDHFactories implements DHFactory {
* @param name The factory name - ignored if {@code null}/empty
* @return The registered extension - {@code null} if not found
*/
- public static final DHFactory unregisterExtension(String name) {
+ public static DHFactory unregisterExtension(String name) {
if (GenericUtils.isEmpty(name)) {
return null;
}
@@ -222,7 +222,7 @@ public enum BuiltinDHFactories implements DHFactory {
* @return The matching {@link BuiltinDHFactories} (case <U>insensitive</U>)
* or {@code null} if no match found
*/
- public static final BuiltinDHFactories fromFactoryName(String name) {
+ public static BuiltinDHFactories fromFactoryName(String name) {
return NamedResource.Utils.findByName(name, String.CASE_INSENSITIVE_ORDER, VALUES);
}
@@ -241,15 +241,15 @@ public enum BuiltinDHFactories implements DHFactory {
* <B>Note:</B> it is up to caller to ensure that the list does not
* contain duplicates
*/
- public static final ParseResult parseDHFactoriesList(String dhList) {
+ public static ParseResult parseDHFactoriesList(String dhList) {
return parseDHFactoriesList(GenericUtils.split(dhList, ','));
}
- public static final ParseResult parseDHFactoriesList(String ... dhList) {
+ public static ParseResult parseDHFactoriesList(String ... dhList) {
return parseDHFactoriesList(GenericUtils.isEmpty((Object[]) dhList) ? Collections.<String>emptyList() : Arrays.asList(dhList));
}
- public static final ParseResult parseDHFactoriesList(Collection<String> dhList) {
+ public static ParseResult parseDHFactoriesList(Collection<String> dhList) {
if (GenericUtils.isEmpty(dhList)) {
return ParseResult.EMPTY;
}
@@ -276,7 +276,7 @@ public enum BuiltinDHFactories implements DHFactory {
* @return The factory or {@code null} if it is neither a built-in one
* or a registered extension
*/
- public static final DHFactory resolveFactory(String name) {
+ public static DHFactory resolveFactory(String name) {
if (GenericUtils.isEmpty(name)) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java b/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
index 8ca6a58..2624ef9 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
@@ -114,7 +114,7 @@ public enum BuiltinMacs implements MacFactory {
* or overrides a built-in one or overrides another registered factory
* with the same name (case <U>insensitive</U>).
*/
- public static final void registerExtension(MacFactory extension) {
+ public static void registerExtension(MacFactory extension) {
String name=ValidateUtils.checkNotNull(extension, "No extension provided").getName();
ValidateUtils.checkTrue(fromFactoryName(name) == null, "Extension overrides built-in: %s", name);
@@ -128,7 +128,7 @@ public enum BuiltinMacs implements MacFactory {
* @return A {@link SortedSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static final SortedSet<MacFactory> getRegisteredExtensions() {
+ public static SortedSet<MacFactory> getRegisteredExtensions() {
// TODO for JDK-8 return Collections.emptySortedSet()
synchronized(extensions) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, extensions.values());
@@ -140,7 +140,7 @@ public enum BuiltinMacs implements MacFactory {
* @param name The factory name - ignored if {@code null}/empty
* @return The registered extension - {@code null} if not found
*/
- public static final MacFactory unregisterExtension(String name) {
+ public static MacFactory unregisterExtension(String name) {
if (GenericUtils.isEmpty(name)) {
return null;
}
@@ -199,15 +199,15 @@ public enum BuiltinMacs implements MacFactory {
* factories and the unknown ones. <B>Note:</B> it is up to caller to
* ensure that the lists do not contain duplicates
*/
- public static final ParseResult parseMacsList(String macs) {
+ public static ParseResult parseMacsList(String macs) {
return parseMacsList(GenericUtils.split(macs, ','));
}
- public static final ParseResult parseMacsList(String ... macs) {
+ public static ParseResult parseMacsList(String ... macs) {
return parseMacsList(GenericUtils.isEmpty((Object[]) macs) ? Collections.<String>emptyList() : Arrays.asList(macs));
}
- public static final ParseResult parseMacsList(Collection<String> macs) {
+ public static ParseResult parseMacsList(Collection<String> macs) {
if (GenericUtils.isEmpty(macs)) {
return ParseResult.EMPTY;
}
@@ -235,7 +235,7 @@ public enum BuiltinMacs implements MacFactory {
* @return The factory or {@code null} if it is neither a built-in one
* or a registered extension
*/
- public static final MacFactory resolveFactory(String name) {
+ public static MacFactory resolveFactory(String name) {
if (GenericUtils.isEmpty(name)) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
index 1648b9e..3accdb4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/LocalFileScpTargetStreamResolver.java
@@ -61,12 +61,12 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
}
LinkOption[] options = IoUtils.getLinkOptions(false);
- if (status.booleanValue() && Files.isDirectory(path, options)) {
+ if (status && Files.isDirectory(path, options)) {
String localName = name.replace('/', File.separatorChar); // in case we are running on Windows
file = path.resolve(localName);
- } else if (status.booleanValue() && Files.isRegularFile(path, options)) {
+ } else if (status && Files.isRegularFile(path, options)) {
file = path;
- } else if (!status.booleanValue()) {
+ } else if (!status) {
Path parent = path.getParent();
Boolean parentStatus = IoUtils.checkFileExists(parent, options);
@@ -74,7 +74,7 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
throw new AccessDeniedException("Receive file parent (" + parent + ") existence status cannot be determined for " + path);
}
- if (parentStatus.booleanValue() && Files.isDirectory(parent, options)) {
+ if (parentStatus && Files.isDirectory(parent, options)) {
file = path;
}
}
@@ -88,7 +88,7 @@ public class LocalFileScpTargetStreamResolver extends AbstractLoggingBean implem
throw new AccessDeniedException("Receive file existence status cannot be determined: " + file);
}
- if (fileStatus.booleanValue()) {
+ if (fileStatus) {
if (Files.isDirectory(file, options)) {
throw new IOException("File is a directory: " + file);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
index 88e604a..c685d23 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
@@ -148,7 +148,7 @@ public class ScpHelper extends AbstractLoggingBean {
if (status == null) {
throw new SshException("Target directory " + path + " is most like inaccessible");
}
- if (!status.booleanValue()) {
+ if (!status) {
throw new SshException("Target directory " + path + " does not exist");
}
if (!Files.isDirectory(path, options)) {
@@ -230,10 +230,10 @@ public class ScpHelper extends AbstractLoggingBean {
}
Path file=null;
- if (status.booleanValue() && Files.isDirectory(path, options)) {
+ if (status && Files.isDirectory(path, options)) {
String localName = name.replace('/', File.separatorChar);
file = path.resolve(localName);
- } else if (!status.booleanValue()) {
+ } else if (!status) {
Path parent = path.getParent();
status = IoUtils.checkFileExists(parent, options);
@@ -241,7 +241,7 @@ public class ScpHelper extends AbstractLoggingBean {
throw new AccessDeniedException("Receive directory parent (" + parent + ") existence status cannot be determined for " + path);
}
- if (status.booleanValue() && Files.isDirectory(parent, options)) {
+ if (status && Files.isDirectory(parent, options)) {
file = path;
}
}
@@ -421,13 +421,13 @@ public class ScpHelper extends AbstractLoggingBean {
} else if (Files.isDirectory(file, options)) {
if (!recursive) {
out.write(ScpHelper.WARNING);
- out.write((path.toString().replace(File.separatorChar, '/') + " not a regular file\n").getBytes(StandardCharsets.UTF_8));
+ out.write((path.replace(File.separatorChar, '/') + " not a regular file\n").getBytes(StandardCharsets.UTF_8));
} else {
sendDir(file, preserve, bufferSize);
}
} else {
out.write(ScpHelper.WARNING);
- out.write((path.toString().replace(File.separatorChar, '/') + " unknown file type\n").getBytes(StandardCharsets.UTF_8));
+ out.write((path.replace(File.separatorChar, '/') + " unknown file type\n").getBytes(StandardCharsets.UTF_8));
}
}
} else {
@@ -457,7 +457,7 @@ public class ScpHelper extends AbstractLoggingBean {
if (status == null) {
throw new AccessDeniedException("Send file existence status cannot be determined: " + file);
}
- if (!status.booleanValue()) {
+ if (!status) {
throw new IOException(file + ": no such file or directory");
}
@@ -522,11 +522,9 @@ public class ScpHelper extends AbstractLoggingBean {
ScpTimestamp time = resolver.getTimestamp();
if (preserve && (time != null)) {
- String cmd = new StringBuilder(Long.SIZE)
- .append('T').append(TimeUnit.MILLISECONDS.toSeconds(time.lastModifiedTime)).append(' ').append('0')
- .append(' ').append(TimeUnit.MILLISECONDS.toSeconds(time.lastAccessTime)).append(' ').append('0')
- .append('\n')
- .toString();
+ String cmd = "T" + TimeUnit.MILLISECONDS.toSeconds(time.lastModifiedTime)
+ + ' ' + '0' + ' ' + TimeUnit.MILLISECONDS.toSeconds(time.lastAccessTime)
+ + ' ' + '0' + '\n';
out.write(cmd.getBytes(StandardCharsets.UTF_8));
out.flush();
readAck(false);
@@ -535,12 +533,7 @@ public class ScpHelper extends AbstractLoggingBean {
Set<PosixFilePermission> perms = EnumSet.copyOf(resolver.getPermissions());
String octalPerms = preserve ? getOctalPermissions(perms) : "0644";
String fileName = resolver.getFileName();
- String cmd = new StringBuilder(octalPerms.length() + fileName.length() + Long.SIZE /* some extra delimiters */)
- .append('C').append(octalPerms)
- .append(' ').append(fileSize)
- .append(' ').append(fileName)
- .append('\n')
- .toString();
+ String cmd = "C" + octalPerms + ' ' + fileSize + ' ' + fileName + '\n';
out.write(cmd.getBytes(StandardCharsets.UTF_8));
out.flush();
readAck(false);
@@ -567,32 +560,17 @@ public class ScpHelper extends AbstractLoggingBean {
BasicFileAttributes basic = Files.getFileAttributeView(path, BasicFileAttributeView.class).readAttributes();
if (preserve) {
- StringBuilder buf = new StringBuilder();
- buf.append("T");
- buf.append(basic.lastModifiedTime().to(TimeUnit.SECONDS));
- buf.append(" ");
- buf.append("0");
- buf.append(" ");
- buf.append(basic.lastAccessTime().to(TimeUnit.SECONDS));
- buf.append(" ");
- buf.append("0");
- buf.append("\n");
- out.write(buf.toString().getBytes(StandardCharsets.UTF_8));
+ out.write(("T" + basic.lastModifiedTime().to(TimeUnit.SECONDS) + " "
+ + "0" + " " + basic.lastAccessTime().to(TimeUnit.SECONDS) + " "
+ + "0" + "\n").getBytes(StandardCharsets.UTF_8));
out.flush();
readAck(false);
}
LinkOption[] options = IoUtils.getLinkOptions(false);
Set<PosixFilePermission> perms = IoUtils.getPermissions(path, options);
- StringBuilder buf = new StringBuilder();
- buf.append("D");
- buf.append(preserve ? getOctalPermissions(perms) : "0755");
- buf.append(" ");
- buf.append("0"); // length
- buf.append(" ");
- buf.append(path.getFileName().toString());
- buf.append("\n");
- out.write(buf.toString().getBytes(StandardCharsets.UTF_8));
+ out.write(("D" + (preserve ? getOctalPermissions(perms) : "0755") + " "
+ + "0" + " " + path.getFileName().toString() + "\n").getBytes(StandardCharsets.UTF_8));
out.flush();
readAck(false);
@@ -660,7 +638,7 @@ public class ScpHelper extends AbstractLoggingBean {
}
}
- return String.format("%04o", Integer.valueOf(pf));
+ return String.format("%04o", pf);
}
public static Set<PosixFilePermission> setOctalPermissions(Path path, String str) throws IOException {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
index e3c7678..3d43fa2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/AbstractConnectionService.java
@@ -146,7 +146,7 @@ public abstract class AbstractConnectionService extends CloseableUtils.AbstractI
throw new IllegalStateException("Session is being closed: " + toString());
}
- channels.put(Integer.valueOf(channelId), channel);
+ channels.put(channelId, channel);
}
if (log.isDebugEnabled()) {
@@ -162,7 +162,7 @@ public abstract class AbstractConnectionService extends CloseableUtils.AbstractI
*/
@Override
public void unregisterChannel(Channel channel) {
- channels.remove(Integer.valueOf(channel.getId()));
+ channels.remove(channel.getId());
}
@Override
@@ -230,7 +230,7 @@ public abstract class AbstractConnectionService extends CloseableUtils.AbstractI
public void channelOpenFailure(Buffer buffer) throws IOException {
AbstractClientChannel channel = (AbstractClientChannel) getChannel(buffer);
- Integer id = Integer.valueOf(channel.getId());
+ int id = channel.getId();
if (log.isDebugEnabled()) {
log.debug("Received SSH_MSG_CHANNEL_OPEN_FAILURE on channel {}", id);
}
@@ -328,7 +328,7 @@ public abstract class AbstractConnectionService extends CloseableUtils.AbstractI
*/
protected Channel getChannel(Buffer buffer) throws IOException {
int recipient = buffer.getInt();
- Channel channel = channels.get(Integer.valueOf(recipient));
+ Channel channel = channels.get(recipient);
if (channel == null) {
buffer.rpos(buffer.rpos() - 5);
int cmd = buffer.getUByte();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java b/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
index 5c5b1d4..6efddd1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
@@ -137,7 +137,7 @@ public enum BuiltinSignatures implements SignatureFactory {
* or overrides a built-in one or overrides another registered factory
* with the same name (case <U>insensitive</U>).
*/
- public static final void registerExtension(SignatureFactory extension) {
+ public static void registerExtension(SignatureFactory extension) {
String name=ValidateUtils.checkNotNull(extension, "No extension provided").getName();
ValidateUtils.checkTrue(fromFactoryName(name) == null, "Extension overrides built-in: %s", name);
@@ -151,7 +151,7 @@ public enum BuiltinSignatures implements SignatureFactory {
* @return A {@link SortedSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static final SortedSet<SignatureFactory> getRegisteredExtensions() {
+ public static SortedSet<SignatureFactory> getRegisteredExtensions() {
// TODO for JDK-8 return Collections.emptySortedSet()
synchronized(extensions) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, extensions.values());
@@ -163,7 +163,7 @@ public enum BuiltinSignatures implements SignatureFactory {
* @param name The factory name - ignored if {@code null}/empty
* @return The registered extension - {@code null} if not found
*/
- public static final SignatureFactory unregisterExtension(String name) {
+ public static SignatureFactory unregisterExtension(String name) {
if (GenericUtils.isEmpty(name)) {
return null;
}
@@ -225,15 +225,15 @@ public enum BuiltinSignatures implements SignatureFactory {
* <B>Note:</B> it is up to caller to ensure that the list does not
* contain duplicates
*/
- public static final ParseResult parseSignatureList(String sigs) {
+ public static ParseResult parseSignatureList(String sigs) {
return parseSignatureList(GenericUtils.split(sigs, ','));
}
- public static final ParseResult parseSignatureList(String ... sigs) {
+ public static ParseResult parseSignatureList(String ... sigs) {
return parseSignatureList(GenericUtils.isEmpty((Object[]) sigs) ? Collections.<String>emptyList() : Arrays.asList(sigs));
}
- public static final ParseResult parseSignatureList(Collection<String> sigs) {
+ public static ParseResult parseSignatureList(Collection<String> sigs) {
if (GenericUtils.isEmpty(sigs)) {
return ParseResult.EMPTY;
}
@@ -261,7 +261,7 @@ public enum BuiltinSignatures implements SignatureFactory {
* @return The factory or {@code null} if it is neither a built-in one
* or a registered extension
*/
- public static final SignatureFactory resolveFactory(String name) {
+ public static SignatureFactory resolveFactory(String name) {
if (GenericUtils.isEmpty(name)) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/signature/Signature.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/signature/Signature.java b/sshd-core/src/main/java/org/apache/sshd/common/signature/Signature.java
index 30b448d..dbac318 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/signature/Signature.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/signature/Signature.java
@@ -40,7 +40,7 @@ public interface Signature {
void initVerifier(PublicKey key) throws Exception;
/**
- * @param prvkey The {@link PrivateKey} to be used for signing
+ * @param key The {@link PrivateKey} to be used for signing
* @throws Exception If failed to initialize
*/
void initSigner(PrivateKey key) throws Exception;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
index b00ee88..e390f80 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
@@ -123,7 +123,7 @@ public final class ParserUtils {
}
}
- public static final List<ExtensionParser<?>> getRegisteredParsers() {
+ public static List<ExtensionParser<?>> getRegisteredParsers() {
synchronized(parsersMap) {
if (parsersMap.isEmpty()) {
return Collections.emptyList();
@@ -133,7 +133,7 @@ public final class ParserUtils {
}
}
- public static final Set<String> supportedExtensions(Map<String,?> parsed) {
+ public static Set<String> supportedExtensions(Map<String,?> parsed) {
if (GenericUtils.isEmpty(parsed)) {
return Collections.emptySet();
}
@@ -163,7 +163,7 @@ public final class ParserUtils {
* @see #getRegisteredParser(String)
* @see ExtensionParser#transform(Object)
*/
- public static final Map<String,Object> parse(Map<String,byte[]> extensions) {
+ public static Map<String,Object> parse(Map<String,byte[]> extensions) {
if (GenericUtils.isEmpty(extensions)) {
return Collections.emptyMap();
}
@@ -181,7 +181,7 @@ public final class ParserUtils {
return data;
}
- public static final Object parse(String name, byte ... encoded) {
+ public static Object parse(String name, byte ... encoded) {
ExtensionParser<?> parser = getRegisteredParser(name);
if (parser == null) {
return null;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/util/Base64.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/Base64.java b/sshd-core/src/main/java/org/apache/sshd/common/util/Base64.java
index d8ce356..7a897c7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/Base64.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/Base64.java
@@ -162,8 +162,8 @@ public class Base64 {
// shouldn't a 0 length array be valid base64 data?
return true;
}
- for (int i = 0; i < length; i++) {
- if (!isBase64(arrayOctect[i])) {
+ for (byte anArrayOctect : arrayOctect) {
+ if (!isBase64(anArrayOctect)) {
return false;
}
}
@@ -239,8 +239,8 @@ public class Base64 {
int lengthDataBits = binaryData.length * EIGHTBIT;
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
- byte encodedData[] = null;
- int encodedDataLength = 0;
+ byte encodedData[];
+ int encodedDataLength;
int nbrChunks = 0;
if (fewerThan24bits != 0) {
@@ -364,13 +364,13 @@ public class Base64 {
}
int numberQuadruple = base64Data.length / FOURBYTE;
- byte decodedData[] = null;
- byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
+ byte decodedData[];
+ byte b1, b2, b3, b4, marker0, marker1;
// Throw away anything not in base64Data
int encodedIndex = 0;
- int dataIndex = 0;
+ int dataIndex;
{
// this sizes the output array properly - rlw
int lastData = base64Data.length;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c80bb65/sshd-core/src/main/java/org/apache/sshd/common/util/DirectoryScanner.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/DirectoryScanner.java b/sshd-core/src/main/java/org/apache/sshd/common/util/DirectoryScanner.java
index 8c48e33..95ab94d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/DirectoryScanner.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/DirectoryScanner.java
@@ -228,7 +228,7 @@ public class DirectoryScanner {
throw new IllegalStateException("No includes set ");
}
- filesIncluded = new ArrayList<String>();
+ filesIncluded = new ArrayList<>();
scandir(basedir, "");
@@ -252,9 +252,9 @@ public class DirectoryScanner {
newfiles = new String[0];
}
- for (int i = 0; i < newfiles.length; i++) {
- String name = vpath + newfiles[i];
- File file = new File(dir, newfiles[i]);
+ for (String newfile : newfiles) {
+ String name = vpath + newfile;
+ File file = new File(dir, newfile);
if (file.isDirectory()) {
if (isIncluded(name)) {
filesIncluded.add(name);
@@ -293,8 +293,8 @@ public class DirectoryScanner {
* include pattern, or <code>false</code> otherwise.
*/
protected boolean isIncluded(String name) {
- for (int i = 0; i < includes.length; i++) {
- if (SelectorUtils.matchPath(includes[i], name, isCaseSensitive)) {
+ for (String include : includes) {
+ if (SelectorUtils.matchPath(include, name, isCaseSensitive)) {
return true;
}
}
@@ -310,8 +310,8 @@ public class DirectoryScanner {
* least one include pattern, or <code>false</code> otherwise.
*/
protected boolean couldHoldIncluded(String name) {
- for (int i = 0; i < includes.length; i++) {
- if (SelectorUtils.matchPatternStart(includes[i], name, isCaseSensitive)) {
+ for (String include : includes) {
+ if (SelectorUtils.matchPatternStart(include, name, isCaseSensitive)) {
return true;
}
}
@@ -361,8 +361,8 @@ public class DirectoryScanner {
return text;
}
- StringBuffer buf = new StringBuffer(text.length());
- int start = 0, end = 0;
+ StringBuilder buf = new StringBuilder(text.length());
+ int start = 0, end;
while ((end = text.indexOf(repl, start)) != -1) {
buf.append(text.substring(start, end)).append(with);
start = end + repl.length();