This is an automated email from the ASF dual-hosted git repository. lgoldstein pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit f46390c69e4a002179335dd200e79b2e84eb208c Author: Lyor Goldstein <lgoldst...@apache.org> AuthorDate: Wed Jul 22 11:48:36 2020 +0300 [SSHD-1035] Fixed some compiler warnings related to the property definitions re-factoring --- .../apache/sshd/common/CommonModuleProperties.java | 4 ++-- .../main/java/org/apache/sshd/common/Property.java | 3 ++- .../java/org/apache/sshd/common/util/OsUtils.java | 10 +++++----- .../security/eddsa/Ed25519PEMResourceKeyParser.java | 2 +- .../sshd/common/config/SshConfigFileReader.java | 1 - .../org/apache/sshd/common/io/nio2/Nio2Service.java | 10 +++++----- .../sshd/common/config/SshConfigFileReaderTest.java | 19 ------------------- .../apache/sshd/common/io/nio2/Nio2ServiceTest.java | 8 ++++---- .../main/java/org/apache/sshd/mina/MinaService.java | 2 +- .../java/org/apache/sshd/sftp/client/SftpClient.java | 1 + .../java/org/apache/sshd/sftp/client/SftpTest.java | 2 +- .../org/apache/sshd/sftp/client/SftpVersionsTest.java | 2 +- 12 files changed, 23 insertions(+), 41 deletions(-) diff --git a/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java b/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java index 6b68052..c3da143 100644 --- a/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java +++ b/sshd-common/src/main/java/org/apache/sshd/common/CommonModuleProperties.java @@ -48,8 +48,8 @@ public final class CommonModuleProperties { = Property.bool("allow-non-integrity-auth", false); /** - * Property used to register the {@link SessionHeartbeatController.HeartbeatType} - if non-existent or {@code NONE} - * then disabled. Same if some unknown string value is set as the property value. + * Property used to register the {@link org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType} - + * if non-existent or {@code NONE} then disabled. Same if some unknown string value is set as the property value. */ public static final Property<SessionHeartbeatController.HeartbeatType> SESSION_HEARTBEAT_TYPE = Property.enum_("session-connection-heartbeat-type", SessionHeartbeatController.HeartbeatType.class, diff --git a/sshd-common/src/main/java/org/apache/sshd/common/Property.java b/sshd-common/src/main/java/org/apache/sshd/common/Property.java index f5ad335..2e89385 100644 --- a/sshd-common/src/main/java/org/apache/sshd/common/Property.java +++ b/sshd-common/src/main/java/org/apache/sshd/common/Property.java @@ -28,7 +28,8 @@ import java.util.function.Consumer; /** * Property definition. * - * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> + * @param <T> The generic property type + * @author <a href="mailto:d...@mina.apache.org">Apache MINA SSHD Project</a> */ public interface Property<T> { diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java index 182afe0..4f98d7d 100644 --- a/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java +++ b/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java @@ -91,7 +91,7 @@ public final class OsUtils { /** * Can be used to enforce Win32 or Linux report from {@link #isWin32()}, {@link #isOSX()} or {@link #isUNIX()} - * + * * @param os The value to set - if {@code null} then O/S type is auto-detected * @see #isWin32() * @see #isOSX() @@ -104,7 +104,7 @@ public final class OsUtils { } /** - * Retrieve the OS + * @return The O/S type string value (lowercase) */ private static String getOS() { String typeValue; @@ -213,7 +213,7 @@ public final class OsUtils { /** * Can be used to programmatically set the username reported by {@link #getCurrentUser()} - * + * * @param username The username to set - if {@code null} then {@link #CURRENT_USER_OVERRIDE_PROP} will be consulted */ public static void setCurrentUser(String username) { @@ -225,7 +225,7 @@ public final class OsUtils { /** * Resolves the reported Java version by consulting {@link #JAVA_VERSION_OVERRIDE_PROP}. If not set, then * "java.version" property is used - * + * * @return The resolved {@link VersionInfo} - never {@code null} * @see #setJavaVersion(VersionInfo) */ @@ -260,7 +260,7 @@ public final class OsUtils { /** * Set programmatically the reported Java version - * + * * @param version The version - if {@code null} then it will be automatically resolved */ public static void setJavaVersion(VersionInfo version) { diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PEMResourceKeyParser.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PEMResourceKeyParser.java index b658340..054111e 100644 --- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PEMResourceKeyParser.java +++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PEMResourceKeyParser.java @@ -61,7 +61,7 @@ public class Ed25519PEMResourceKeyParser extends AbstractPEMResourceKeyPairParse public static final List<String> ENDERS = Collections.unmodifiableList(Collections.singletonList(END_MARKER)); /** - * @see <A HREF="https://tools.ietf.org/html/rfc8410#section-3>RFC8412 section 3</A> + * @see <A HREF="https://tools.ietf.org/html/rfc8410#section-3">RFC8412 section 3</A> */ public static final String ED25519_OID = "1.3.101.112"; 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 6aa3b52..163fe57 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 @@ -248,7 +248,6 @@ public final class SshConfigFileReader { * thrown * @return The configured manager * @see ConfigFileReaderSupport#KEX_ALGORITHMS_CONFIG_PROP KEX_ALGORITHMS_CONFIG_PROP - * @see ConfigFileReaderSupport#DEFAULT_KEX_ALGORITHMS DEFAULT_KEX_ALGORITHMS */ public static <M extends AbstractFactoryManager> M configureKeyExchanges( M manager, PropertyResolver props, boolean lenient, 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 0f82ef3..d9e2b54 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 @@ -52,10 +52,10 @@ import org.apache.sshd.core.CoreModuleProperties; */ public abstract class Nio2Service extends AbstractInnerCloseable implements IoService, FactoryManagerHolder { // Note: order may be important so that's why we use a LinkedHashMap - public static final Map<Property, SimpleImmutableEntry<SocketOption<?>, Object>> CONFIGURABLE_OPTIONS; + public static final Map<Property<?>, SimpleImmutableEntry<SocketOption<?>, Object>> CONFIGURABLE_OPTIONS; static { - Map<Property, SimpleImmutableEntry<SocketOption<?>, Object>> map = new LinkedHashMap<>(); + Map<Property<?>, SimpleImmutableEntry<SocketOption<?>, Object>> map = new LinkedHashMap<>(); map.put(CoreModuleProperties.SOCKET_KEEPALIVE, new SimpleImmutableEntry<>(StandardSocketOptions.SO_KEEPALIVE, null)); map.put(CoreModuleProperties.SOCKET_LINGER, new SimpleImmutableEntry<>(StandardSocketOptions.SO_LINGER, null)); map.put(CoreModuleProperties.SOCKET_RCVBUF, new SimpleImmutableEntry<>(StandardSocketOptions.SO_RCVBUF, null)); @@ -159,8 +159,8 @@ public abstract class Nio2Service extends AbstractInnerCloseable implements IoSe return socket; } - for (Map.Entry<Property, ? extends Map.Entry<SocketOption<?>, ?>> ce : CONFIGURABLE_OPTIONS.entrySet()) { - Property property = ce.getKey(); + for (Map.Entry<Property<?>, ? extends Map.Entry<SocketOption<?>, ?>> ce : CONFIGURABLE_OPTIONS.entrySet()) { + Property<?> property = ce.getKey(); Map.Entry<SocketOption<?>, ?> defConfig = ce.getValue(); @SuppressWarnings("rawtypes") SocketOption option = defConfig.getKey(); @@ -171,7 +171,7 @@ public abstract class Nio2Service extends AbstractInnerCloseable implements IoSe } protected <T> boolean setOption( - NetworkChannel socket, Property property, SocketOption<T> option, T defaultValue) + NetworkChannel socket, Property<?> property, SocketOption<T> option, T defaultValue) throws IOException { PropertyResolver manager = getFactoryManager(); String valStr = manager.getString(property.getName()); diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java index 9b529d9..62c55c8 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java @@ -118,25 +118,6 @@ public class SshConfigFileReaderTest extends BaseTestSupport { testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories()); } - private static void testKnownDefaultFactoriesList( - String factories, Function<? super String, ? extends NamedResource> resolver) { - testKnownDefaultFactoriesList(factories, resolver, Collections.emptySet()); - } - - private static void testKnownDefaultFactoriesList( - String factories, Function<? super String, ? extends NamedResource> resolver, Collection<String> excludedNames) { - String[] names = GenericUtils.split(factories, ','); - assertTrue("No default names", GenericUtils.length(names) > 0); - for (String n : names) { - NamedResource facInstance = resolver.apply(n); - if (excludedNames.contains(n)) { - assertNull("Unexpected excluded factory instance: " + n, facInstance); - } else { - assertNotNull("Unknown factory: " + n, facInstance); - } - } - } - @Test public void testGetCompression() { Properties props = new Properties(); diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java index 1896ce6..2a25db0 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java @@ -57,14 +57,14 @@ public class Nio2ServiceTest extends BaseTestSupport { @Test // see SSHD-554, SSHD-722 public void testSetSocketOptions() throws Exception { try (SshServer sshd = setupTestServer()) { - Map<Property, Object> expectedOptions = new LinkedHashMap<>(); + Map<Property<?>, Object> expectedOptions = new LinkedHashMap<>(); expectedOptions.put(CoreModuleProperties.SOCKET_KEEPALIVE, true); expectedOptions.put(CoreModuleProperties.SOCKET_LINGER, 5); expectedOptions.put(CoreModuleProperties.SOCKET_RCVBUF, 1024); expectedOptions.put(CoreModuleProperties.SOCKET_REUSEADDR, true); expectedOptions.put(CoreModuleProperties.SOCKET_SNDBUF, 1024); expectedOptions.put(CoreModuleProperties.TCP_NODELAY, true); - for (Map.Entry<Property, ?> oe : expectedOptions.entrySet()) { + for (Map.Entry<Property<?>, ?> oe : expectedOptions.entrySet()) { PropertyResolverUtils.updateProperty(sshd, oe.getKey().getName(), oe.getValue()); } @@ -89,8 +89,8 @@ public class Nio2ServiceTest extends BaseTestSupport { return; } - for (Map.Entry<Property, ?> oe : expectedOptions.entrySet()) { - Property prop = oe.getKey(); + for (Map.Entry<Property<?>, ?> oe : expectedOptions.entrySet()) { + Property<?> prop = oe.getKey(); Object expValue = oe.getValue(); Map.Entry<SocketOption<?>, ?> optionEntry = Nio2Service.CONFIGURABLE_OPTIONS.get(prop); SocketOption<?> option = optionEntry.getKey(); diff --git a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java index cc3bf45..99f4712 100644 --- a/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java +++ b/sshd-mina/src/main/java/org/apache/sshd/mina/MinaService.java @@ -212,7 +212,7 @@ public abstract class MinaService extends AbstractCloseable } protected void handleConfigurationError( - SocketSessionConfig config, Property property, Object propValue, RuntimeIoException t) { + SocketSessionConfig config, Property<?> property, Object propValue, RuntimeIoException t) { Throwable e = GenericUtils.resolveExceptionCause(t); log.warn("handleConfigurationError({}={}) failed ({}) to configure: {}", property.getName(), propValue, e.getClass().getSimpleName(), e.getMessage()); diff --git a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/SftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/SftpClient.java index 97293aa..c81ff55 100644 --- a/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/SftpClient.java +++ b/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/SftpClient.java @@ -46,6 +46,7 @@ import org.apache.sshd.client.subsystem.SubsystemClient; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ValidateUtils; import org.apache.sshd.common.util.buffer.BufferUtils; +import org.apache.sshd.sftp.SftpModuleProperties; import org.apache.sshd.sftp.client.extensions.SftpClientExtension; import org.apache.sshd.sftp.common.SftpConstants; import org.apache.sshd.sftp.common.SftpHelper; diff --git a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java index 6a1fd3e..3b66eda 100644 --- a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java +++ b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpTest.java @@ -136,7 +136,7 @@ public class SftpTest extends AbstractSftpClientTestSupport { setupServer(); Map<String, Object> props = sshd.getProperties(); - Object forced = props.remove(SftpModuleProperties.SFTP_VERSION); + Object forced = props.remove(SftpModuleProperties.SFTP_VERSION.getName()); if (forced != null) { outputDebugMessage("Removed forced version=%s", forced); } diff --git a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpVersionsTest.java b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpVersionsTest.java index 931fb2d..b9eb048 100644 --- a/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpVersionsTest.java +++ b/sshd-sftp/src/test/java/org/apache/sshd/sftp/client/SftpVersionsTest.java @@ -103,7 +103,7 @@ public class SftpVersionsTest extends AbstractSftpClientTestSupport { setupServer(); Map<String, Object> props = sshd.getProperties(); - Object forced = props.remove(SftpModuleProperties.SFTP_VERSION); + Object forced = props.remove(SftpModuleProperties.SFTP_VERSION.getName()); if (forced != null) { outputDebugMessage("Removed forced version=%s", forced); }