Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-11-11 14:59:07 +0000
committerAlexander Kurtakov2017-11-11 14:59:07 +0000
commitcacd6d9d1d85adb919af8c12beb22643e76ce17d (patch)
tree66fd1e3c4719189a547f1073cc82d083f9174c80
parent19752d9abc811e3593f031d2e8aa42290191909d (diff)
downloadrt.equinox.bundles-cacd6d9d1d85adb919af8c12beb22643e76ce17d.tar.gz
rt.equinox.bundles-cacd6d9d1d85adb919af8c12beb22643e76ce17d.tar.xz
rt.equinox.bundles-cacd6d9d1d85adb919af8c12beb22643e76ce17d.zip
Bug 527146 - Move equinox.console to Java 8I20171111-1500
Modernize the codebase with Java 8 constructs. Update console.tests bundle too. Change-Id: Id3c9ec868e6526fc9c3298138317d578db4c834c Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/.classpath3
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/.settings/org.eclipse.jdt.core.prefs110
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/META-INF/MANIFEST.MF4
-rw-r--r--bundles/archived/org.eclipse.equinox.console.tests/pom.xml2
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/Activator.java35
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/ActivatorTests.java9
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapterTest.java5
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleInputStreamTests.java54
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java21
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CommandNamesCompleterTests.java4
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CompletionHandlerTests.java14
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/FileNamesCompleterTests.java10
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/StringsCompleterTests.java4
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/VariableNamesCompleterTests.java4
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputHandlerTests.java62
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputScannerTests.java8
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandTests.java10
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandWithConfigAdminTests.java61
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetConnectionTests.java106
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetDisconnectionTest.java144
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputHandlerTests.java14
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputScannerTests.java9
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetOutputStreamTests.java37
-rwxr-xr-xbundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetServerTests.java156
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/.settings/org.eclipse.jdt.core.prefs26
-rw-r--r--bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java15
-rw-r--r--bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeysFileAuthenticator.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/RolePrincipal.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/SecureStorageLoginModule.java7
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/UserPrincipal.java6
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/Activator.java17
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshCommand.java18
-rw-r--r--bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshServ.java5
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshSession.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java12
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java5
-rwxr-xr-xbundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/storage/SecureUserStore.java60
-rwxr-xr-xbundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs25
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java82
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java36
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java11
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java38
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java8
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java15
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java10
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java13
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java11
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java5
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java8
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java3
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java9
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java4
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java14
-rwxr-xr-xbundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java11
64 files changed, 743 insertions, 681 deletions
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/.classpath b/bundles/archived/org.eclipse.equinox.console.tests/.classpath
index a7d4b6245..eca7bdba8 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/.classpath
+++ b/bundles/archived/org.eclipse.equinox.console.tests/.classpath
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/archived/org.eclipse.equinox.console.tests/.settings/org.eclipse.jdt.core.prefs
index af0f20f97..4a1d02020 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/archived/org.eclipse.equinox.console.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,111 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/META-INF/MANIFEST.MF b/bundles/archived/org.eclipse.equinox.console.tests/META-INF/MANIFEST.MF
index aa559b375..6abdf9aeb 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/META-INF/MANIFEST.MF
+++ b/bundles/archived/org.eclipse.equinox.console.tests/META-INF/MANIFEST.MF
@@ -2,9 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Console tests
Bundle-SymbolicName: org.eclipse.equinox.console.tests
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 1.1.0.qualifier
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: junit.framework;version="4.8.1",
org.apache.sshd.client.future,
org.easymock;version="2.4.0",
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/pom.xml b/bundles/archived/org.eclipse.equinox.console.tests/pom.xml
index 3584b3632..2e2ebdfd6 100644
--- a/bundles/archived/org.eclipse.equinox.console.tests/pom.xml
+++ b/bundles/archived/org.eclipse.equinox.console.tests/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.console.tests</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/Activator.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/Activator.java
deleted file mode 100755
index e024b14fa..000000000
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/Activator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 SAP AG
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Lazar Kirchev, SAP AG - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.console;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator implements BundleActivator {
- private static BundleContext context;
-
- public void start(BundleContext context) throws Exception {
- this.context = context;
- }
-
-
- public void stop(BundleContext context) throws Exception {
- this.context = null;
- }
-
- public static BundleContext getContext() {
- return context;
- }
-}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/ActivatorTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/ActivatorTests.java
index 677fc4099..a07cab450 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/ActivatorTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/ActivatorTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -30,7 +30,7 @@ public class ActivatorTests {
@Test
public void testGetCommandMethods() {
- Set<String> commandNames = new HashSet<String>();
+ Set<String> commandNames = new HashSet<>();
commandNames.add("_testMethod1");
commandNames.add("_testMethod2");
commandNames.add("_testMethod3");
@@ -67,10 +67,7 @@ public class ActivatorTests {
}
- private void _method(CommandInterpreter i) {
-
- }
-
+ @Override
public String getHelp() {
// TODO Auto-generated method stub
return null;
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapterTest.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapterTest.java
index 91ce5f5d2..153cf08a0 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapterTest.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,7 @@ public class CommandProviderAdapterTest {
public void testMain() throws Exception {
CommandProvider provider = new TestCommandProvider();
Method[] methods = TestCommandProvider.class.getMethods();
- Set<Method> m = new HashSet<Method>();
+ Set<Method> m = new HashSet<>();
for (Method method : methods) {
if (method.getName().startsWith("_")) {
m.add(method);
@@ -54,6 +54,7 @@ public class CommandProviderAdapterTest {
return i.nextArgument();
}
+ @Override
public String getHelp() {
return "this is a test command provider";
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleInputStreamTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleInputStreamTests.java
index b3732bbfc..815c5bcd9 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleInputStreamTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleInputStreamTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,28 +18,34 @@ import org.eclipse.equinox.console.common.ConsoleInputStream;
public class ConsoleInputStreamTests {
- private static final int DATA_LENGTH = 4;
-
- @Test
- public void addReadBufferTest() throws Exception {
- ConsoleInputStream in = new ConsoleInputStream();
- byte[] data = new byte[] { (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd' };
- in.add(data);
- byte[] read = new byte[DATA_LENGTH];
- for (int i = 0; i < DATA_LENGTH; i++) {
- in.read(read, i, 1);
- Assert.assertEquals("Incorrect char read; position " + i + " expected: " + data[i] + ", actual: " + read[i], read[i], data[i]);
- }
- }
+ private static final int DATA_LENGTH = 4;
- @Test
- public void addReadTest() throws Exception {
- ConsoleInputStream in = new ConsoleInputStream();
- byte[] data = new byte[] { (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd' };
- in.add(data);
- for (int i = 0; i < DATA_LENGTH; i++) {
- byte symbol = (byte) in.read();
- Assert.assertEquals("Incorrect char read; position " + i + " expected: " + data[i] + ", actual: " + symbol, symbol, data[i]);
- }
- }
+ @Test
+ public void addReadBufferTest() throws Exception {
+ try (ConsoleInputStream in = new ConsoleInputStream()) {
+ byte[] data = new byte[] { (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd' };
+ in.add(data);
+ byte[] read = new byte[DATA_LENGTH];
+ for (int i = 0; i < DATA_LENGTH; i++) {
+ in.read(read, i, 1);
+ Assert.assertEquals(
+ "Incorrect char read; position " + i + " expected: " + data[i] + ", actual: " + read[i],
+ read[i], data[i]);
+ }
+ }
+ }
+
+ @Test
+ public void addReadTest() throws Exception {
+ try (ConsoleInputStream in = new ConsoleInputStream()) {
+ byte[] data = new byte[] { (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd' };
+ in.add(data);
+ for (int i = 0; i < DATA_LENGTH; i++) {
+ byte symbol = (byte) in.read();
+ Assert.assertEquals(
+ "Incorrect char read; position " + i + " expected: " + data[i] + ", actual: " + symbol, symbol,
+ data[i]);
+ }
+ }
+ }
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java
index c1044ee8b..4c241d875 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/common/ConsoleOutputStreamTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,19 +23,20 @@ public class ConsoleOutputStreamTests {
@Test
public void testWrite() throws Exception {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- ConsoleOutputStream out = new ConsoleOutputStream(byteOut);
- byte[] data = new byte[] { 'a', 'b', 'c', 'd' };
- for (byte b : data) {
- out.write(b);
- }
- out.flush();
- byte[] res = byteOut.toByteArray();
-
- Assert.assertNotNull("Bytes not written; result null", res);
+ try (ConsoleOutputStream out = new ConsoleOutputStream(byteOut)) {
+ byte[] data = new byte[] { 'a', 'b', 'c', 'd' };
+ for (byte b : data) {
+ out.write(b);
+ }
+ out.flush();
+ byte[] res = byteOut.toByteArray();
+
+ Assert.assertNotNull("Bytes not written; result null", res);
Assert.assertFalse("Bytes not written; result empty", res.length == 0);
for (int i = 0; i < DATA_LENGTH; i++) {
Assert.assertEquals("Wrong char read. Position " + i + ", expected " + data[i] + ", read " + res[i], data[i], res[i]);
}
+ }
}
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CommandNamesCompleterTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CommandNamesCompleterTests.java
index dcbd19c86..f416a217e 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CommandNamesCompleterTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CommandNamesCompleterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,7 +31,7 @@ public class CommandNamesCompleterTests {
@Test
public void testGetCandidates() throws Exception {
- Set<String> commands = new HashSet<String>();
+ Set<String> commands = new HashSet<>();
commands.add("equinox:bundles");
commands.add("equinox:diag");
commands.add("equinox:setprop");
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CompletionHandlerTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CompletionHandlerTests.java
index 07663db15..4d2122e8c 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CompletionHandlerTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/CompletionHandlerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -72,13 +72,13 @@ public class CompletionHandlerTests {
expect(context.getServiceReferences("org.eclipse.equinox.console.commands.CommandsTracker", null)).andReturn(new ServiceReference[]{}).anyTimes();
replay(context);
- Set<String> variables = new HashSet<String>();
+ Set<String> variables = new HashSet<>();
variables.add("SCOPE");
variables.add("PROMPT");
variables.add("ECHO_ON");
variables.add("ECHO");
- Set<String> commands = new HashSet<String>();
+ Set<String> commands = new HashSet<>();
commands.add("equinox:bundles");
commands.add("equinox:diag");
commands.add("equinox:setprop");
@@ -166,10 +166,10 @@ public class CompletionHandlerTests {
private void createFile(File parentDir, String filename) throws IOException {
File file = new File(parentDir.getAbsolutePath() + File.separator + filename);
- PrintWriter out = new PrintWriter(new FileOutputStream(file));
- out.write(filename);
- out.flush();
- out.close();
+ try (PrintWriter out = new PrintWriter(new FileOutputStream(file))) {
+ out.write(filename);
+ out.flush();
+ }
}
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/FileNamesCompleterTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/FileNamesCompleterTests.java
index 91540a13f..e79a9d462 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/FileNamesCompleterTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/FileNamesCompleterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -89,9 +89,9 @@ public class FileNamesCompleterTests {
private void createFile(File parentDir, String filename) throws IOException {
File file = new File(parentDir.getAbsolutePath() + File.separator + filename);
- PrintWriter out = new PrintWriter(new FileOutputStream(file));
- out.write(filename);
- out.flush();
- out.close();
+ try (PrintWriter out = new PrintWriter(new FileOutputStream(file))) {
+ out.write(filename);
+ out.flush();
+ }
}
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/StringsCompleterTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/StringsCompleterTests.java
index 05096ba5b..0df1581d1 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/StringsCompleterTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/StringsCompleterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,7 +23,7 @@ public class StringsCompleterTests {
@Test
public void testGetCandidates() {
- Set<String> strings = new HashSet<String>();
+ Set<String> strings = new HashSet<>();
strings.add("command");
strings.add("SCOPE");
strings.add("equinox:bundles");
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/VariableNamesCompleterTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/VariableNamesCompleterTests.java
index 2b6ca5290..a753beeba 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/VariableNamesCompleterTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/completion/VariableNamesCompleterTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,7 +25,7 @@ public class VariableNamesCompleterTests {
@Test
public void testGetCandidates() {
- Set<String> variables = new HashSet<String>();
+ Set<String> variables = new HashSet<>();
variables.add("SCOPE");
variables.add("PROMPT");
variables.add("ECHO_ON");
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputHandlerTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputHandlerTests.java
index e595b627c..f04b6cfab 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputHandlerTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputHandlerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,35 +22,35 @@ import java.io.PipedOutputStream;
public class ConsoleInputHandlerTests {
- private static final long WAIT_TIME = 10000;
-
- @Test
- public void testHandler() throws Exception {
- PipedInputStream input = new PipedInputStream();
- PipedOutputStream output = new PipedOutputStream(input);
- ConsoleInputStream in = new ConsoleInputStream();
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- ConsoleInputHandler handler = new ConsoleInputHandler(input, in, byteOut);
- byte[] testInput = new byte[] { 'a', 'b', 'c', 'd', 'e', '\r', '\n' };
- byte[] expected = new byte[] { 'a', 'b', 'c', 'd', 'e', '\n' };
- output.write(testInput);
- output.flush();
- handler.start();
-
- try {
- Thread.sleep(WAIT_TIME);
- } catch (Exception e) {
- // do nothing
- }
-
- byte[] read = new byte[expected.length];
- in.read(read, 0, expected.length);
- for (int i = 0; i < expected.length; i++) {
- Assert.assertEquals("Incorrect char read. Position " + i + ", expected " + expected[i] + ", read " + read[i], expected[i], read[i]);
- }
-
- output.close();
- input.close();
- }
+ private static final long WAIT_TIME = 10000;
+
+ @Test
+ public void testHandler() throws Exception {
+ try (PipedInputStream input = new PipedInputStream(); PipedOutputStream output = new PipedOutputStream(input)) {
+ ConsoleInputStream in = new ConsoleInputStream();
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ ConsoleInputHandler handler = new ConsoleInputHandler(input, in, byteOut);
+ byte[] testInput = new byte[] { 'a', 'b', 'c', 'd', 'e', '\r', '\n' };
+ byte[] expected = new byte[] { 'a', 'b', 'c', 'd', 'e', '\n' };
+ output.write(testInput);
+ output.flush();
+ handler.start();
+
+ try {
+ Thread.sleep(WAIT_TIME);
+ } catch (Exception e) {
+ // do nothing
+ }
+
+ byte[] read = new byte[expected.length];
+ in.read(read, 0, expected.length);
+ for (int i = 0; i < expected.length; i++) {
+ Assert.assertEquals(
+ "Incorrect char read. Position " + i + ", expected " + expected[i] + ", read " + read[i],
+ expected[i], read[i]);
+ }
+
+ }
+ }
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputScannerTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputScannerTests.java
index 5c07ca1fb..6c9459a38 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputScannerTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/supportability/ConsoleInputScannerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -60,7 +60,7 @@ public class ConsoleInputScannerTests {
@Test
public void test() throws Exception {
- Set<TerminalTypeMappings> supportedEscapeSequences = new HashSet<TerminalTypeMappings>();
+ Set<TerminalTypeMappings> supportedEscapeSequences = new HashSet<>();
supportedEscapeSequences.add(new ANSITerminalTypeMappings());
supportedEscapeSequences.add(new VT100TerminalTypeMappings());
supportedEscapeSequences.add(new VT220TerminalTypeMappings());
@@ -69,7 +69,7 @@ public class ConsoleInputScannerTests {
for (TerminalTypeMappings ttMappings : supportedEscapeSequences) {
Map<String, KEYS> escapesToKey = ttMappings.getEscapesToKey();
- Map<KEYS, byte[]> keysToEscapes = new HashMap<KEYS, byte[]>();
+ Map<KEYS, byte[]> keysToEscapes = new HashMap<>();
for (Entry<String, KEYS> entry : escapesToKey.entrySet()) {
keysToEscapes.put(entry.getValue(), entry.getKey().getBytes());
}
@@ -194,7 +194,7 @@ public class ConsoleInputScannerTests {
expect(context.getServiceReferences("org.eclipse.equinox.console.commands.CommandsTracker", null)).andReturn(new ServiceReference[]{});
replay(context);
- Set<String> commands = new HashSet<String>();
+ Set<String> commands = new HashSet<>();
commands.add("equinox:bundles");
commands.add("equinox:bundle");
commands.add("gogo:bundlebylocation");
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandTests.java
index 5cd1f9f89..ec84f8abf 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandTests.java
@@ -37,7 +37,7 @@ public class TelnetCommandTests {
@Test
public void testTelnetCommand() throws Exception {
- CommandSession session = EasyMock.createMock(CommandSession.class);
+ try (CommandSession session = EasyMock.createMock(CommandSession.class)) {
session.put((String)EasyMock.anyObject(), EasyMock.anyObject());
EasyMock.expectLastCall().times(3);
EasyMock.expect(session.execute((String)EasyMock.anyObject())).andReturn(new Object());
@@ -58,9 +58,7 @@ public class TelnetCommandTests {
TelnetCommand command = new TelnetCommand(processor, context);
command.startService();
- Socket socketClient = null;
- try {
- socketClient = new Socket(HOST, TELNET_PORT);
+ try (Socket socketClient = new Socket(HOST, TELNET_PORT);){
OutputStream outClient = socketClient.getOutputStream();
outClient.write(TEST_CONTENT);
outClient.write('\n');
@@ -73,11 +71,9 @@ public class TelnetCommandTests {
// do nothing
}
} finally {
- if (socketClient != null) {
- socketClient.close();
- }
command.telnet(new String[] {STOP_COMMAND});
}
EasyMock.verify(context);
+ }
}
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandWithConfigAdminTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandWithConfigAdminTests.java
index 15480ef54..eaf4b6bb8 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandWithConfigAdminTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetCommandWithConfigAdminTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,35 +10,21 @@
*******************************************************************************/
package org.eclipse.equinox.console.telnet;
-import java.io.File;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
-import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
-import junit.framework.Assert;
-
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.easymock.EasyMock;
-import org.easymock.IAnswer;
import org.eclipse.equinox.console.common.ConsoleInputStream;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ManagedService;
@@ -69,7 +55,7 @@ public class TelnetCommandWithConfigAdminTests {
EasyMock.replay(processor);
final ServiceRegistration<?> registration = EasyMock.createMock(ServiceRegistration.class);
- registration.setProperties((Dictionary)EasyMock.anyObject());
+ registration.setProperties((Dictionary<String, ?>)EasyMock.anyObject());
EasyMock.expectLastCall();
EasyMock.replay(registration);
@@ -81,11 +67,9 @@ public class TelnetCommandWithConfigAdminTests {
(String)EasyMock.anyObject(),
(ManagedService)EasyMock.anyObject(),
(Dictionary<String, ?>)EasyMock.anyObject())
- ).andAnswer((IAnswer<ServiceRegistration<?>>) new IAnswer<ServiceRegistration<?>>() {
- public ServiceRegistration<?> answer() {
- configurator = (ManagedService) EasyMock.getCurrentArguments()[1];
- return registration;
- }
+ ).andAnswer(() -> {
+ configurator = (ManagedService) EasyMock.getCurrentArguments()[1];
+ return registration;
});
EasyMock.expect(
context.registerService(
@@ -96,15 +80,13 @@ public class TelnetCommandWithConfigAdminTests {
TelnetCommand command = new TelnetCommand(processor, context);
command.startService();
- Dictionary props = new Hashtable();
+ Dictionary<String, String> props = new Hashtable<>();
props.put("port", TELNET_PORT);
props.put("host", HOST);
props.put("enabled", TRUE);
configurator.updated(props);
- Socket socketClient = null;
- try {
- socketClient = new Socket(HOST, Integer.parseInt(TELNET_PORT));
+ try (Socket socketClient = new Socket(HOST, Integer.parseInt(TELNET_PORT));){
OutputStream outClient = socketClient.getOutputStream();
outClient.write(TEST_CONTENT);
outClient.write('\n');
@@ -117,9 +99,6 @@ public class TelnetCommandWithConfigAdminTests {
// do nothing
}
} finally {
- if (socketClient != null) {
- socketClient.close();
- }
command.telnet(new String[] {STOP_COMMAND});
}
EasyMock.verify(context);
@@ -149,7 +128,7 @@ public class TelnetCommandWithConfigAdminTests {
EasyMock.replay(processor);
final ServiceRegistration<?> registration = EasyMock.createMock(ServiceRegistration.class);
- registration.setProperties((Dictionary)EasyMock.anyObject());
+ registration.setProperties((Dictionary<String, ?>)EasyMock.anyObject());
EasyMock.expectLastCall();
EasyMock.replay(registration);
@@ -161,11 +140,9 @@ public class TelnetCommandWithConfigAdminTests {
(String)EasyMock.anyObject(),
(ManagedService)EasyMock.anyObject(),
(Dictionary<String, ?>)EasyMock.anyObject())
- ).andAnswer((IAnswer<ServiceRegistration<?>>) new IAnswer<ServiceRegistration<?>>() {
- public ServiceRegistration<?> answer() {
- configurator = (ManagedService) EasyMock.getCurrentArguments()[1];
- return registration;
- }
+ ).andAnswer(() -> {
+ configurator = (ManagedService) EasyMock.getCurrentArguments()[1];
+ return registration;
});
EasyMock.expect(
context.registerService(
@@ -176,7 +153,7 @@ public class TelnetCommandWithConfigAdminTests {
TelnetCommand command = new TelnetCommand(processor, context);
command.startService();
- Dictionary props = new Hashtable();
+ Dictionary<String, String> props = new Hashtable<>();
props.put("port", TELNET_PORT);
props.put("host", HOST);
if (isDefault == false) {
@@ -184,16 +161,12 @@ public class TelnetCommandWithConfigAdminTests {
}
configurator.updated(props);
- Socket socketClient = null;
- try {
- socketClient = new Socket(HOST, Integer.parseInt(TELNET_PORT));
- Assert.fail("It should not be possible to open a socket to " + HOST + ":" + TELNET_PORT);
+ try (Socket socketClient = new Socket(HOST, Integer.parseInt(TELNET_PORT))){
+
+ fail("It should not be possible to open a socket to " + HOST + ":" + TELNET_PORT);
} catch (IOException e) {
// this is ok, there should be an exception
} finally {
- if (socketClient != null) {
- socketClient.close();
- }
try {
command.telnet(new String[] {STOP_COMMAND});
} catch (IllegalStateException e) {
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetConnectionTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetConnectionTests.java
index bebcd222f..005d9cbad 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetConnectionTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetConnectionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,73 +27,55 @@ import java.net.Socket;
public class TelnetConnectionTests {
private static final String HOST = "localhost";
- private static final int TEST_CONTENT = 100;
- private static final int IAC = 255;
+ private static final int TEST_CONTENT = 100;
+ private static final int IAC = 255;
- @Test
- public void testTelneConnection() throws Exception {
- ServerSocket servSocket = null;
- Socket socketClient = null;
- Socket socketServer = null;
- TelnetConnection connection = null;
- OutputStream outClient = null;
- OutputStream outServer = null;
+ @Test
+ public void testTelneConnection() throws Exception {
- try {
- servSocket = new ServerSocket(0);
- socketClient = new Socket(HOST, servSocket.getLocalPort());
- socketServer = servSocket.accept();
+ try (ServerSocket servSocket = new ServerSocket(0);
+ Socket socketClient = new Socket(HOST, servSocket.getLocalPort());
+ Socket socketServer = servSocket.accept();
+ CommandSession session = EasyMock.createMock(CommandSession.class)) {
- CommandSession session = EasyMock.createMock(CommandSession.class);
- session.put((String)EasyMock.anyObject(), EasyMock.anyObject());
- EasyMock.expectLastCall().times(3);
- EasyMock.expect(session.execute((String)EasyMock.anyObject())).andReturn(null);
- session.close();
- EasyMock.expectLastCall();
- EasyMock.replay(session);
-
- CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
- EasyMock.expect(processor.createSession((ConsoleInputStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject())).andReturn(session);
- EasyMock.replay(processor);
-
- connection = new TelnetConnection(socketServer, processor, null);
- connection.start();
+ session.put((String) EasyMock.anyObject(), EasyMock.anyObject());
+ EasyMock.expectLastCall().times(3);
+ EasyMock.expect(session.execute((String) EasyMock.anyObject())).andReturn(null);
+ session.close();
+ EasyMock.expectLastCall();
+ EasyMock.replay(session);
- outClient = socketClient.getOutputStream();
- outClient.write(TEST_CONTENT);
- outClient.write('\n');
- outClient.flush();
+ CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
+ EasyMock.expect(processor.createSession((ConsoleInputStream) EasyMock.anyObject(),
+ (PrintStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject())).andReturn(session);
+ EasyMock.replay(processor);
- InputStream input = socketServer.getInputStream();
- int in = input.read();
- Assert.assertTrue("Server received [" + in + "] instead of " + TEST_CONTENT + " from the telnet client.", in == TEST_CONTENT);
+ try (TelnetConnection connection = new TelnetConnection(socketServer, processor, null)) {
+ connection.start();
- input = socketClient.getInputStream();
- in = input.read();
- // here IAC is expected, since when the output stream in TelnetConsoleSession is created, several telnet
- // commands are written to it, each of them starting with IAC
- Assert.assertTrue("Client receive telnet responses from the server unexpected value [" + in + "] instead of " + IAC + ".", in == IAC);
- connection.telnetNegotiationFinished();
- Thread.sleep(5000);
- EasyMock.verify(session, processor);
- } finally {
- if (socketClient != null) {
- socketClient.close();
- }
- if (outClient != null) {
- outClient.close();
- }
- if (outServer != null) {
- outServer.close();
- }
+ try (OutputStream outClient = socketClient.getOutputStream()) {
+ outClient.write(TEST_CONTENT);
+ outClient.write('\n');
+ outClient.flush();
- if (socketServer != null) {
- socketServer.close();
- }
+ InputStream input = socketServer.getInputStream();
+ int in = input.read();
+ Assert.assertTrue(
+ "Server received [" + in + "] instead of " + TEST_CONTENT + " from the telnet client.",
+ in == TEST_CONTENT);
- if (servSocket != null) {
- servSocket.close();
- }
- }
- }
+ input = socketClient.getInputStream();
+ in = input.read();
+ // here IAC is expected, since when the output stream in TelnetConsoleSession is
+ // created, several telnet
+ // commands are written to it, each of them starting with IAC
+ Assert.assertTrue("Client receive telnet responses from the server unexpected value [" + in
+ + "] instead of " + IAC + ".", in == IAC);
+ connection.telnetNegotiationFinished();
+ Thread.sleep(5000);
+ EasyMock.verify(session, processor);
+ }
+ }
+ }
+ }
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetDisconnectionTest.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetDisconnectionTest.java
index 066f5c3d7..84f25cbb5 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetDisconnectionTest.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetDisconnectionTest.java
@@ -1,7 +1,6 @@
package org.eclipse.equinox.console.telnet;
import java.io.InputStream;
-import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
@@ -19,86 +18,65 @@ import org.osgi.framework.BundleContext;
public class TelnetDisconnectionTest {
private static final String HOST = "localhost";
- private InputStream in;
-
- @Test
- public void testTelneConnection() throws Exception {
- ServerSocket servSocket = null;
- Socket socketClient = null;
- Socket socketServer = null;
- TelnetConnection connection = null;
- OutputStream outClient = null;
- OutputStream outServer = null;
-
- try {
- servSocket = new ServerSocket(0);
- socketClient = new Socket(HOST, servSocket.getLocalPort());
- socketServer = servSocket.accept();
-
- CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
- connection = new TelnetConnection(socketServer, processor, null);
-
- final CommandSession session = EasyMock.createMock(CommandSession.class);
- EasyMock.makeThreadSafe(session, true);
- session.put((String)EasyMock.anyObject(), EasyMock.anyObject());
- EasyMock.expectLastCall().times(3);
- EasyMock.expect(session.get("CLOSEABLE")).andReturn(connection);
- EasyMock.expect(session.execute((String)EasyMock.anyObject())).andReturn(null);
- session.close();
- EasyMock.expectLastCall();
- EasyMock.replay(session);
-
- EasyMock.expect(processor.createSession((ConsoleInputStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject())).andReturn(session);
- EasyMock.replay(processor);
-
- connection.start();
- Thread.sleep(60000);
-
- BundleContext context = EasyMock.createMock(BundleContext.class);
- final DisconnectCommand command = new DisconnectCommand(context);
-
- PipedOutputStream outputStream = new PipedOutputStream();
- PipedInputStream inputStream = new PipedInputStream(outputStream);
-
- in = System.in;
- System.setIn(inputStream);
-
- new Thread() {
- public void run() {
- command.disconnect(session);
- }
- }.start();
-
- outputStream.write(new byte[]{'y'});
- outputStream.write('\n');
- outputStream.flush();
-
- Thread.sleep(3000);
- Assert.assertTrue("Socket is not closed!", socketServer.isClosed());
-
- connection.telnetNegotiationFinished();
- Thread.sleep(5000);
- EasyMock.verify(session, processor);
- } finally {
- if (socketClient != null) {
- socketClient.close();
- }
- if (outClient != null) {
- outClient.close();
- }
- if (outServer != null) {
- outServer.close();
- }
-
- if (socketServer != null) {
- socketServer.close();
- }
-
- if (servSocket != null) {
- servSocket.close();
- }
-
- System.setIn(in);
- }
- }
+ private InputStream in;
+
+ @Test
+ public void testTelneConnection() throws Exception {
+ TelnetConnection connection = null;
+
+ try (ServerSocket servSocket = new ServerSocket(0);
+ Socket socketClient = new Socket(HOST, servSocket.getLocalPort());
+ Socket socketServer = servSocket.accept();
+ CommandSession session = EasyMock.createMock(CommandSession.class)) {
+
+ CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
+ connection = new TelnetConnection(socketServer, processor, null);
+
+ EasyMock.makeThreadSafe(session, true);
+ session.put((String) EasyMock.anyObject(), EasyMock.anyObject());
+ EasyMock.expectLastCall().times(3);
+ EasyMock.expect(session.get("CLOSEABLE")).andReturn(connection);
+ EasyMock.expect(session.execute((String) EasyMock.anyObject())).andReturn(null);
+ session.close();
+ EasyMock.expectLastCall();
+ EasyMock.replay(session);
+
+ EasyMock.expect(processor.createSession((ConsoleInputStream) EasyMock.anyObject(),
+ (PrintStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject())).andReturn(session);
+ EasyMock.replay(processor);
+
+ connection.start();
+ Thread.sleep(60000);
+
+ BundleContext context = EasyMock.createMock(BundleContext.class);
+ final DisconnectCommand command = new DisconnectCommand(context);
+
+ PipedOutputStream outputStream = new PipedOutputStream();
+ PipedInputStream inputStream = new PipedInputStream(outputStream);
+
+ in = System.in;
+ System.setIn(inputStream);
+
+ new Thread() {
+ @Override
+ public void run() {
+ command.disconnect(session);
+ }
+ }.start();
+
+ outputStream.write(new byte[] { 'y' });
+ outputStream.write('\n');
+ outputStream.flush();
+
+ Thread.sleep(3000);
+ Assert.assertTrue("Socket is not closed!", socketServer.isClosed());
+
+ connection.telnetNegotiationFinished();
+ Thread.sleep(5000);
+ EasyMock.verify(session, processor);
+ } finally {
+
+ System.setIn(in);
+ }
+ }
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputHandlerTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputHandlerTests.java
index f5d3bd6a8..3a67aec6a 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputHandlerTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputHandlerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,23 +11,23 @@
package org.eclipse.equinox.console.telnet;
+import static org.easymock.EasyMock.createMock;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
import org.eclipse.equinox.console.common.ConsoleInputStream;
import org.eclipse.equinox.console.common.ConsoleOutputStream;
import org.junit.Assert;
import org.junit.Test;
-import static org.easymock.EasyMock.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.StringBufferInputStream;
-
public class TelnetInputHandlerTests {
private static final long WAIT_TIME = 10000;
@Test
public void testHandler() throws Exception {
- StringBufferInputStream input = new StringBufferInputStream("abcde");
+ ByteArrayInputStream input = new ByteArrayInputStream("abcde".getBytes());
ConsoleInputStream in = new ConsoleInputStream();
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ConsoleOutputStream out = new ConsoleOutputStream(byteOut);
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputScannerTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputScannerTests.java
index 679597358..a0730a6c6 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputScannerTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetInputScannerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -96,7 +96,7 @@ public class TelnetInputScannerTests {
try {
scanner.scan((byte) 'a');
- scanner.scan((byte) ESC);
+ scanner.scan(ESC);
scanner.scan((byte) 'b');
} catch (IOException e) {
System.out.println("Error while scanning: " + e.getMessage());
@@ -110,7 +110,7 @@ public class TelnetInputScannerTests {
@Test
public void testTTNegotiations() throws Exception {
- Map<byte[], TerminalTypeMappings> ttMappings = new HashMap<byte[], TerminalTypeMappings>();
+ Map<byte[], TerminalTypeMappings> ttMappings = new HashMap<>();
ttMappings.put(new byte[] { 'A', 'N', 'S', 'I' }, new ANSITerminalTypeMappings());
ttMappings.put(new byte[] { 'V', 'T', '1', '0', '0' }, new VT100TerminalTypeMappings());
ttMappings.put(new byte[] { 'V', 'T', '2', '2', '0' }, new VT220TerminalTypeMappings());
@@ -211,7 +211,8 @@ public class TelnetInputScannerTests {
private boolean isCalled = false;
- public void finished() {
+ @Override
+ public void finished() {
isCalled = true;
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetOutputStreamTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetOutputStreamTests.java
index f975f4dc7..8ff848d47 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetOutputStreamTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetOutputStreamTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,21 +19,26 @@ import java.io.ByteArrayOutputStream;
public class TelnetOutputStreamTests {
@Test
- public void testAutoSend() throws Exception {
- ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
- TelnetOutputStream out = new TelnetOutputStream(byteOut);
- out.autoSend();
- out.flush();
- byte[] message = byteOut.toByteArray();
+ public void testAutoSend() throws Exception {
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ try (TelnetOutputStream out = new TelnetOutputStream(byteOut)) {
+ out.autoSend();
+ out.flush();
+ byte[] message = byteOut.toByteArray();
- Assert.assertNotNull("Auto message not sent", message);
- Assert.assertFalse("Auto message not sent", message.length == 0);
- Assert.assertTrue("Error sending auto message. Expected length: " + TelnetOutputStream.autoMessage.length + ", actual length: "
- + message.length, message.length == TelnetOutputStream.autoMessage.length);
+ Assert.assertNotNull("Auto message not sent", message);
+ Assert.assertFalse("Auto message not sent", message.length == 0);
+ Assert.assertTrue(
+ "Error sending auto message. Expected length: " + TelnetOutputStream.autoMessage.length
+ + ", actual length: " + message.length,
+ message.length == TelnetOutputStream.autoMessage.length);
- for (int i = 0; i < message.length; i++) {
- Assert.assertEquals("Wrong char in auto message. Position: " + i + ", expected: " + TelnetOutputStream.autoMessage[i] + ", read: "
- + message[i], TelnetOutputStream.autoMessage[i], message[i]);
- }
- }
+ for (int i = 0; i < message.length; i++) {
+ Assert.assertEquals(
+ "Wrong char in auto message. Position: " + i + ", expected: "
+ + TelnetOutputStream.autoMessage[i] + ", read: " + message[i],
+ TelnetOutputStream.autoMessage[i], message[i]);
+ }
+ }
+ }
}
diff --git a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetServerTests.java b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetServerTests.java
index 21eb4c546..6cf209a49 100755
--- a/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetServerTests.java
+++ b/bundles/archived/org.eclipse.equinox.console.tests/src/org/eclipse/equinox/console/telnet/TelnetServerTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,90 +36,84 @@ public class TelnetServerTests {
@Test
public void testTelnetServer() throws Exception {
+ try (CommandSession session = EasyMock.createMock(CommandSession.class)) {
+ session.put((String) EasyMock.anyObject(), EasyMock.anyObject());
+ EasyMock.expectLastCall().times(3);
+ EasyMock.expect(session.execute((String) EasyMock.anyObject())).andReturn(new Object());
+ session.close();
+ EasyMock.expectLastCall();
+ EasyMock.replay(session);
- CommandSession session = EasyMock.createMock(CommandSession.class);
- session.put((String)EasyMock.anyObject(), EasyMock.anyObject());
- EasyMock.expectLastCall().times(3);
- EasyMock.expect(session.execute((String)EasyMock.anyObject())).andReturn(new Object());
- session.close();
- EasyMock.expectLastCall();
- EasyMock.replay(session);
-
- CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
- EasyMock.expect(processor.createSession((ConsoleInputStream)EasyMock.anyObject(), (PrintStream)EasyMock.anyObject(), (PrintStream)EasyMock.anyObject())).andReturn(session);
- EasyMock.replay(processor);
-
- List<CommandProcessor> processors = new ArrayList<CommandProcessor>();
- processors.add(processor);
- TelnetServer telnetServer = new TelnetServer(null, processors, HOST, PORT);
- telnetServer.start();
- Socket socketClient = null;
-
- try {
- socketClient = new Socket("localhost", PORT);
- OutputStream outClient = socketClient.getOutputStream();
- outClient.write(TEST_CONTENT);
- outClient.write('\n');
- outClient.flush();
- // wait for the accept thread to finish execution
- try {
- Thread.sleep(WAIT_TIME);
- } catch (InterruptedException ie) {
- // do nothing
- }
- verify();
- } catch(ConnectException e) {
- Assert.fail("Telnet port not open");
- } finally {
- if (socketClient != null) {
- socketClient.close();
- }
- telnetServer.stopTelnetServer();
- }
+ CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
+ EasyMock.expect(processor.createSession((ConsoleInputStream) EasyMock.anyObject(),
+ (PrintStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject())).andReturn(session);
+ EasyMock.replay(processor);
+
+ List<CommandProcessor> processors = new ArrayList<>();
+ processors.add(processor);
+ TelnetServer telnetServer = new TelnetServer(null, processors, HOST, PORT);
+ telnetServer.start();
+
+ try (Socket socketClient = new Socket("localhost", PORT);) {
+
+ OutputStream outClient = socketClient.getOutputStream();
+ outClient.write(TEST_CONTENT);
+ outClient.write('\n');
+ outClient.flush();
+ // wait for the accept thread to finish execution
+ try {
+ Thread.sleep(WAIT_TIME);
+ } catch (InterruptedException ie) {
+ // do nothing
+ }
+ verify();
+ } catch (ConnectException e) {
+ Assert.fail("Telnet port not open");
+ } finally {
+ telnetServer.stopTelnetServer();
+ }
+ }
}
@Test
- public void testTelnetServerWithoutHost() throws Exception {
- CommandSession session = EasyMock.createMock(CommandSession.class);
- session.put((String)EasyMock.anyObject(), EasyMock.anyObject());
- EasyMock.expectLastCall().times(4);
- EasyMock.expect(session.execute((String)EasyMock.anyObject())).andReturn(new Object());
- session.close();
- EasyMock.expectLastCall();
- EasyMock.replay(session);
-
- CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
- EasyMock.expect(processor.createSession((ConsoleInputStream)EasyMock.anyObject(), (PrintStream)EasyMock.anyObject(), (PrintStream)EasyMock.anyObject())).andReturn(session);
- EasyMock.replay(processor);
-
- List<CommandProcessor> processors = new ArrayList<CommandProcessor>();
- processors.add(processor);
- TelnetServer telnetServer = new TelnetServer(null, processors, null, PORT);
- telnetServer.start();
- Socket socketClient = null;
-
- try {
- socketClient = new Socket("localhost", PORT);
- OutputStream outClient = socketClient.getOutputStream();
- outClient.write(TEST_CONTENT);
- outClient.write('\n');
- outClient.flush();
-
- // wait for the accept thread to finish execution
- try {
- Thread.sleep(WAIT_TIME);
- } catch (InterruptedException ie) {
- // do nothing
- }
- } catch(ConnectException e) {
- Assert.fail("Telnet port not open");
- } finally {
- if (socketClient != null) {
- socketClient.close();
- }
- telnetServer.stopTelnetServer();
- }
+ public void testTelnetServerWithoutHost() throws Exception {
+ try (CommandSession session = EasyMock.createMock(CommandSession.class)) {
+ session.put((String) EasyMock.anyObject(), EasyMock.anyObject());
+ EasyMock.expectLastCall().times(4);
+ EasyMock.expect(session.execute((String) EasyMock.anyObject())).andReturn(new Object());
+ session.close();
+ EasyMock.expectLastCall();
+ EasyMock.replay(session);
- }
+ CommandProcessor processor = EasyMock.createMock(CommandProcessor.class);
+ EasyMock.expect(processor.createSession((ConsoleInputStream) EasyMock.anyObject(),
+ (PrintStream) EasyMock.anyObject(), (PrintStream) EasyMock.anyObject())).andReturn(session);
+ EasyMock.replay(processor);
+
+ List<CommandProcessor> processors = new ArrayList<>();
+ processors.add(processor);
+ TelnetServer telnetServer = new TelnetServer(null, processors, null, PORT);
+ telnetServer.start();
+
+ try (Socket socketClient = new Socket("localhost", PORT);) {
+ OutputStream outClient = socketClient.getOutputStream();
+ outClient.write(TEST_CONTENT);
+ outClient.write('\n');
+ outClient.flush();
+
+ // wait for the accept thread to finish execution
+ try {
+ Thread.sleep(WAIT_TIME);
+ } catch (InterruptedException ie) {
+ // do nothing
+ }
+ } catch (ConnectException e) {
+ Assert.fail("Telnet port not open");
+ } finally {
+ telnetServer.stopTelnetServer();
+ }
+ }
+
+ }
}
diff --git a/bundles/org.eclipse.equinox.console.ssh/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.console.ssh/.settings/org.eclipse.jdt.core.prefs
index d8d8453d5..5c5368266 100755
--- a/bundles/org.eclipse.equinox.console.ssh/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.console.ssh/.settings/org.eclipse.jdt.core.prefs
@@ -2,16 +2,21 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -21,7 +26,7 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
@@ -34,14 +39,14 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@@ -49,20 +54,22 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
@@ -71,19 +78,24 @@ org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java
index 1e3284d14..be0f1a843 100644
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2011 Gunnar Wagenknecht and others.
+ * Copyright (c) 2011, 2017 Gunnar Wagenknecht and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
@@ -98,12 +98,11 @@ public class AuthorizedKeys {
public AuthorizedKeys(final String authorizedKeysFile) throws FileNotFoundException, IOException {
// read file line-by-line
final File file = new File(authorizedKeysFile);
- final Scanner scanner = new Scanner(file);
- scanner.useDelimiter(NEWLINE);
- int lineNumber = 0;
- final List<PublicKey> keys = new ArrayList<PublicKey>();
+ try (Scanner scanner = new Scanner(file)) {
+ scanner.useDelimiter(NEWLINE);
+ int lineNumber = 0;
+ final List<PublicKey> keys = new ArrayList<>();
- try {
while (scanner.hasNext()) {
lineNumber++;
@@ -122,11 +121,9 @@ public class AuthorizedKeys {
throw new ParseKeyException("Line " + lineNumber + ": " + e.getMessage(), e);
}
}
- } finally {
- scanner.close();
+ this.keys = Collections.unmodifiableList(keys);
}
- this.keys = Collections.unmodifiableList(keys);
}
/**
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeysFileAuthenticator.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeysFileAuthenticator.java
index 5abd2be74..2a538cf85 100644
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeysFileAuthenticator.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeysFileAuthenticator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2012 Gunnar Wagenknecht and others.
+ * Copyright (c) 2012, 2017 Gunnar Wagenknecht and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
@@ -35,6 +35,7 @@ public class AuthorizedKeysFileAuthenticator implements PublickeyAuthenticator {
this.authorizedKeysFile = authorizedKeysFile;
}
+ @Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
String authorizedKeysFile = getAuthorizedKeysFile();
if(null == authorizedKeysFile) {
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/RolePrincipal.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/RolePrincipal.java
index c5f8c4ad4..2d03c7b18 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/RolePrincipal.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/RolePrincipal.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,10 +24,12 @@ public class RolePrincipal implements Principal {
this.roleName = roleName;
}
+ @Override
public String getName() {
return roleName;
}
+ @Override
public boolean equals(Object role) {
if (role == null) {
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/SecureStorageLoginModule.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/SecureStorageLoginModule.java
index 941fb17e6..b5b39c61a 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/SecureStorageLoginModule.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/SecureStorageLoginModule.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -39,12 +39,14 @@ public class SecureStorageLoginModule implements LoginModule {
private volatile UserPrincipal userPrincipal;
private volatile boolean isSuccess;
+ @Override
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
}
+ @Override
public boolean login() throws LoginException {
NameCallback nameCallback = new NameCallback("username: ");
PasswordCallback passwordCallback = new PasswordCallback("password: ", false);
@@ -74,6 +76,7 @@ public class SecureStorageLoginModule implements LoginModule {
}
}
+ @Override
public boolean commit() throws LoginException {
if (isSuccess == true) {
synchronized (this) {
@@ -88,12 +91,14 @@ public class SecureStorageLoginModule implements LoginModule {
}
}
+ @Override
public boolean abort() throws LoginException {
userPrincipal.destroy();
userPrincipal = null;
return true;
}
+ @Override
public boolean logout() throws LoginException {
synchronized (this) {
subject.getPrincipals().remove(userPrincipal);
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/UserPrincipal.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/UserPrincipal.java
index 7af4162a1..b07dab0c1 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/UserPrincipal.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/jaas/UserPrincipal.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,7 +22,7 @@ import java.util.Set;
public class UserPrincipal implements Principal {
private String username;
private char[] password;
- private Set<RolePrincipal> rolePrincipals = new HashSet<RolePrincipal>();
+ private Set<RolePrincipal> rolePrincipals = new HashSet<>();
public UserPrincipal(String username, String password) {
this.username = username;
@@ -30,6 +30,7 @@ public class UserPrincipal implements Principal {
System.arraycopy(password.toCharArray(), 0, this.password, 0, this.password.length);
}
+ @Override
public String getName() {
return username;
}
@@ -64,6 +65,7 @@ public class UserPrincipal implements Principal {
rolePrincipals.add(rolePrincipal);
}
+ @Override
public boolean equals(Object userPrincipal) {
if (userPrincipal == null) {
return false;
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/Activator.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/Activator.java
index 84b656897..bf0ca26eb 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/Activator.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,6 +33,7 @@ public class Activator implements BundleActivator {
this.context = context;
}
+ @Override
public SshCommand addingService(ServiceReference<CommandProcessor> reference) {
CommandProcessor processor = context.getService(reference);
if (processor == null)
@@ -49,12 +50,14 @@ public class Activator implements BundleActivator {
return sshConnection;
}
+ @Override
public void modifiedService(
ServiceReference<CommandProcessor> reference,
SshCommand service) {
// nothing
}
+ @Override
public void removedService(ServiceReference<CommandProcessor> reference, SshCommand service) {
CommandProcessor processor = context.getService(reference);
service.removeCommandProcessor(processor);
@@ -65,20 +68,14 @@ public class Activator implements BundleActivator {
return context;
}
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
+ @Override
public void start(BundleContext bundleContext) throws Exception {
context = bundleContext;
- commandProcessorTracker = new ServiceTracker<CommandProcessor, SshCommand>(context, CommandProcessor.class, new ProcessorCustomizer(context));
+ commandProcessorTracker = new ServiceTracker<>(context, CommandProcessor.class, new ProcessorCustomizer(context));
commandProcessorTracker.open();
}
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
+ @Override
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
commandProcessorTracker.close();
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshCommand.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshCommand.java
index 80e3c7f2d..0cf0f2a6b 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshCommand.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2013 SAP AG and others.
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,7 +36,7 @@ import org.osgi.service.cm.ManagedService;
public class SshCommand {
private String defaultHost = null;
private int defaultPort;
- private List<CommandProcessor> processors = new ArrayList<CommandProcessor>();
+ private List<CommandProcessor> processors = new ArrayList<>();
private String host = null;
private int port;
private SshServ sshServ;
@@ -59,7 +59,7 @@ public class SshCommand {
this.context = context;
if ("true".equals(context.getProperty(USE_CONFIG_ADMIN_PROP))) {
- Dictionary<String, String> sshProperties = new Hashtable<String, String>();
+ Dictionary<String, String> sshProperties = new Hashtable<>();
sshProperties.put(Constants.SERVICE_PID, SSH_PID);
try {
synchronized (lock) {
@@ -95,7 +95,7 @@ public class SshCommand {
}
public synchronized void startService() {
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ Dictionary<String, Object> properties = new Hashtable<>();
properties.put("osgi.command.scope", "equinox");
properties.put("osgi.command.function", new String[] {"ssh"});
if ((port > 0 || defaultPort > 0) && isEnabled == true) {
@@ -211,15 +211,9 @@ public class SshCommand {
}
private void checkPortAvailable(int port) throws Exception {
- ServerSocket socket = null;
- try {
- socket = new ServerSocket(port);
+ try (ServerSocket socket = new ServerSocket(port)){
} catch (BindException e) {
throw new Exception ("Port " + port + " already in use");
- } finally {
- if (socket != null) {
- socket.close();
- }
}
}
@@ -227,7 +221,7 @@ public class SshCommand {
* Register user administration commands
*/
private void registerUserAdmin() {
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ Dictionary<String, Object> properties = new Hashtable<>();
properties.put("osgi.command.scope", "equinox");
properties.put("osgi.command.function", new String[] {"addUser", "addUser", "deleteUser", "resetPassword", "setPassword", "addRoles", "removeRoles", "listUsers"});
context.registerService(UserAdminCommand.class.getName(), new UserAdminCommand(), properties);
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshServ.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshServ.java
index d41f699d0..cc9f0272e 100644
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshServ.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshServ.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -54,7 +54,8 @@ public class SshServ extends Thread {
shellFactory = new SshShellFactory(processors, context);
}
- public void run() throws RuntimeException {
+ @Override
+ public void run() throws RuntimeException {
sshServer = SshServer.setUpDefaultServer();
if (host != null) {
sshServer.setHost(host);
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshSession.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshSession.java
index 2420278f1..a1bef5fe4 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshSession.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshSession.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -63,6 +63,7 @@ public class SshSession extends Thread implements Closeable {
this.currentEscapesToKey = currentExcapesToKey;
}
+ @Override
public void run() {
ConsoleInputStream input = new ConsoleInputStream();
ConsoleOutputStream outp = new ConsoleOutputStream(out);
@@ -128,6 +129,7 @@ public class SshSession extends Thread implements Closeable {
}
+ @Override
public void close() throws IOException {
this.interrupt();
sshShell.removeSession(this);
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java
index 8d03064c0..ece876ce9 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShell.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,7 +44,7 @@ public class SshShell implements Command {
private InputStream in;
private OutputStream out;
private ExitCallback callback;
- private Map<CommandProcessor, SshSession> commandProcessorToConsoleThreadMap = new HashMap<CommandProcessor, SshSession>();
+ private Map<CommandProcessor, SshSession> commandProcessorToConsoleThreadMap = new HashMap<>();
private final Map<String, TerminalTypeMappings> supportedEscapeSequences;
private static final String DEFAULT_TTYPE = File.separatorChar == '/' ? "XTERM" : "ANSI";
@@ -55,7 +55,7 @@ public class SshShell implements Command {
public SshShell(List<CommandProcessor> processors, BundleContext context) {
this.processors = processors;
this.context = context;
- supportedEscapeSequences = new HashMap<String, TerminalTypeMappings> ();
+ supportedEscapeSequences = new HashMap<> ();
supportedEscapeSequences.put("ANSI", new ANSITerminalTypeMappings());
supportedEscapeSequences.put("WINDOWS", new ANSITerminalTypeMappings());
supportedEscapeSequences.put("VT100", new VT100TerminalTypeMappings());
@@ -69,22 +69,27 @@ public class SshShell implements Command {
currentEscapesToKey = currentMappings.getEscapesToKey();
}
+ @Override
public void setInputStream(InputStream in) {
this.in = in;
}
+ @Override
public void setOutputStream(OutputStream out) {
this.out = out;
}
+ @Override
public void setErrorStream(OutputStream err) {
// do nothing
}
+ @Override
public void setExitCallback(ExitCallback callback) {
this.callback = callback;
}
+ @Override
public synchronized void start(Environment env) throws IOException {
String term = env.getEnv().get(TERMINAL_PROPERTY);
TerminalTypeMappings mapping = supportedEscapeSequences.get(term.toUpperCase());
@@ -114,6 +119,7 @@ public class SshShell implements Command {
commandProcessorToConsoleThreadMap.put(processor, consoleSession);
}
+ @Override
public void destroy() {
return;
}
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java
index 82b7964d9..67df36f85 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/ssh/SshShellFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,13 +28,14 @@ public class SshShellFactory implements Factory<Command> {
private List<CommandProcessor> processors;
private BundleContext context;
- private Set<SshShell> shells = new HashSet<SshShell>();
+ private Set<SshShell> shells = new HashSet<>();
public SshShellFactory(List<CommandProcessor> processors, BundleContext context) {
this.processors = processors;
this.context = context;
}
+ @Override
public synchronized Command create() {
SshShell shell = new SshShell(processors, context);
shells.add(shell);
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/storage/SecureUserStore.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/storage/SecureUserStore.java
index dc6bde77f..132356a43 100755
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/storage/SecureUserStore.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/storage/SecureUserStore.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -45,11 +45,10 @@ public class SecureUserStore {
* @return String array containing the usernames
*/
public static String[] getUserNames() {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
try {
@@ -57,7 +56,7 @@ public class SecureUserStore {
} catch (IOException e) {
throw new IllegalArgumentException("Cannot load properties from file " + userFileLoc);
}
- Set<String> userNames = new HashSet<String>();
+ Set<String> userNames = new HashSet<>();
for (Object key : users.keySet()) {
if (!(key instanceof String)) {
continue;
@@ -102,12 +101,11 @@ public class SecureUserStore {
* @param roles comma-separated list of the roles of the user
*/
public static void putUser(String username, String password, String roles) {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
OutputStream out = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -164,16 +162,15 @@ public class SecureUserStore {
* @param roles comma-separated list of new roles for the user
*/
public static void addRoles(String username, String roles) {
- String userFileLoc = null;
+ if (roles == null || roles.length() == 0) {
+ return;
+ }
+
+ String userFileLoc = getFileLocation();
InputStream in = null;
OutputStream out = null;
try {
- if (roles == null || roles.length() == 0) {
- return;
- }
-
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -185,7 +182,7 @@ public class SecureUserStore {
String userRolesKey = constructPropertyName(username, ROLES_KEY);
String currentRoles = (String)users.remove(userRolesKey);
- Set<String> rolesSet = new HashSet<String>();
+ Set<String> rolesSet = new HashSet<>();
if (currentRoles.length() > 0) {
for (String role : currentRoles.split(",")) {
@@ -240,16 +237,14 @@ public class SecureUserStore {
* @param rolesToRemove comma-separated list of roles to be removed
*/
public static void removeRoles(String username, String rolesToRemove) {
- String userFileLoc = null;
+ if(rolesToRemove == null || rolesToRemove.length() == 0) {
+ return;
+ }
+ String userFileLoc = getFileLocation();
InputStream in = null;
OutputStream out = null;
try {
- if(rolesToRemove == null || rolesToRemove.length() == 0) {
- return;
- }
-
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -261,7 +256,7 @@ public class SecureUserStore {
String userRolesKey = constructPropertyName(username, ROLES_KEY);
String currentRoles = (String)users.remove(userRolesKey);
- Set<String> rolesSet = new HashSet<String>();
+ Set<String> rolesSet = new HashSet<>();
for (String role : currentRoles.split(",")) {
rolesSet.add(role);
@@ -313,12 +308,11 @@ public class SecureUserStore {
* @param username user to be removed
*/
public static void deleteUser(String username) {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
OutputStream out = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -377,12 +371,11 @@ public class SecureUserStore {
* @param username user to reset the password
*/
public static void resetPassword(String username) {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
OutputStream out = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -437,12 +430,11 @@ public class SecureUserStore {
* @param password the new password
*/
public static void setPassword(String username, String password) {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
OutputStream out = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -500,10 +492,9 @@ public class SecureUserStore {
* @return true if there is an entry for this user in the store, false otherwise
*/
public static boolean existsUser(String username) {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
@@ -536,24 +527,17 @@ public class SecureUserStore {
String userFileLoc = getFileLocation();
File file = new File(userFileLoc);
if (!file.exists()) {
- OutputStream out = null;
- try {
- Properties props = new Properties();
- out = new FileOutputStream(file);
+ Properties props = new Properties();
+ try (OutputStream out = new FileOutputStream(file);) {
props.store(out, null);
- } finally {
- if (out != null) {
- out.close();
- }
}
}
}
private static String getProperty(String username, String propertyName) {
- String userFileLoc = null;
+ String userFileLoc = getFileLocation();
InputStream in = null;
try {
- userFileLoc = getFileLocation();
in = new FileInputStream(userFileLoc);
Properties users = null;
diff --git a/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs
index d8d8453d5..0cc2336fd 100755
--- a/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.console/.settings/org.eclipse.jdt.core.prefs
@@ -2,8 +2,11 @@ eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
@@ -12,6 +15,7 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -21,7 +25,7 @@ org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
@@ -34,14 +38,14 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@@ -49,20 +53,22 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
@@ -71,19 +77,24 @@ org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
index 4be3b5de7..09c7d8512 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 IBM Corporation, SAP AG.
+ * Copyright (c) 2010, 2017 IBM Corporation, SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,9 +49,9 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
* The activator class controls the plug-in life cycle
*/
public class Activator implements BundleActivator {
- private ServiceTracker<StartLevel, ?> startLevelManagerTracker;
- private ServiceTracker<ConditionalPermissionAdmin, ?> condPermAdminTracker;
- private ServiceTracker<PermissionAdmin, ?> permissionAdminTracker;
+ private ServiceTracker<StartLevel, StartLevel> startLevelManagerTracker;
+ private ServiceTracker<ConditionalPermissionAdmin, ConditionalPermissionAdmin> condPermAdminTracker;
+ private ServiceTracker<PermissionAdmin, PermissionAdmin> permissionAdminTracker;
private ServiceTracker<PackageAdmin, PackageAdmin> packageAdminTracker;
private static boolean isFirstProcessor = true;
private static TelnetCommand telnetConnection = null;
@@ -71,6 +71,7 @@ public class Activator implements BundleActivator {
this.context = context;
}
+ @Override
public ServiceTracker<ConsoleSession, CommandSession> addingService(
ServiceReference<CommandProcessor> reference) {
CommandProcessor processor = context.getService(reference);
@@ -85,17 +86,19 @@ public class Activator implements BundleActivator {
telnetConnection.addCommandProcessor(processor);
}
- ServiceTracker<ConsoleSession, CommandSession> tracker = new ServiceTracker<ConsoleSession, CommandSession>(context, ConsoleSession.class, new SessionCustomizer(context, processor));
+ ServiceTracker<ConsoleSession, CommandSession> tracker = new ServiceTracker<>(context, ConsoleSession.class, new SessionCustomizer(context, processor));
tracker.open();
return tracker;
}
+ @Override
public void modifiedService(
ServiceReference<CommandProcessor> reference,
ServiceTracker<ConsoleSession, CommandSession> service) {
// nothing
}
+ @Override
public void removedService(
ServiceReference<CommandProcessor> reference,
ServiceTracker<ConsoleSession, CommandSession> tracker) {
@@ -116,6 +119,7 @@ public class Activator implements BundleActivator {
this.processor = processor;
}
+ @Override
public CommandSession addingService(
ServiceReference<ConsoleSession> reference) {
final ConsoleSession equinoxSession = context.getService(reference);
@@ -123,31 +127,30 @@ public class Activator implements BundleActivator {
return null;
PrintStream output = new PrintStream(equinoxSession.getOutput());
final CommandSession gogoSession = processor.createSession(equinoxSession.getInput(), output, output);
- new Thread(new Runnable(){
- public void run() {
- try {
- gogoSession.put("SCOPE", "equinox:*");
- gogoSession.put("prompt", "osgi> ");
- gogoSession.execute("gosh --login --noshutdown");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- gogoSession.close();
- equinoxSession.close();
- }
- }
-
+ new Thread((Runnable) () -> {
+ try {
+ gogoSession.put("SCOPE", "equinox:*");
+ gogoSession.put("prompt", "osgi> ");
+ gogoSession.execute("gosh --login --noshutdown");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ gogoSession.close();
+ equinoxSession.close();
+ }
}, "Equinox Console Session").start();
return null;
}
+ @Override
public void modifiedService(ServiceReference<ConsoleSession> reference,
CommandSession service) {
// nothing
}
+ @Override
public void removedService(ServiceReference<ConsoleSession> reference,
CommandSession session) {
session.close();
@@ -163,6 +166,7 @@ public class Activator implements BundleActivator {
this.context = context;
}
+ @Override
public List<ServiceRegistration<?>> addingService(ServiceReference<CommandProvider> reference) {
if (reference.getProperty("osgi.command.function") != null) {
// must be a gogo function already; don' track
@@ -173,8 +177,8 @@ public class Activator implements BundleActivator {
Method[] commandMethods = getCommandMethods(command);
if (commandMethods.length > 0) {
- List<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
- registrations.add(context.registerService(Object.class, new CommandProviderAdapter((CommandProvider) command, commandMethods), getAttributes(commandMethods)));
+ List<ServiceRegistration<?>> registrations = new ArrayList<>();
+ registrations.add(context.registerService(Object.class, new CommandProviderAdapter(command, commandMethods), getAttributes(commandMethods)));
return registrations;
} else {
context.ungetService(reference);
@@ -187,10 +191,12 @@ public class Activator implements BundleActivator {
}
+ @Override
public void modifiedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> service) {
// Nothing to do.
}
+ @Override
public void removedService(ServiceReference<CommandProvider> reference, List<ServiceRegistration<?>> registrations) {
for (ServiceRegistration<?> serviceRegistration : registrations) {
serviceRegistration.unregister();
@@ -199,23 +205,24 @@ public class Activator implements BundleActivator {
}
+ @Override
public void start(BundleContext context) throws Exception {
- commandProviderTracker = new ServiceTracker<CommandProvider, List<ServiceRegistration<?>>>(context, CommandProvider.class.getName(), new CommandCustomizer(context));
+ commandProviderTracker = new ServiceTracker<>(context, CommandProvider.class, new CommandCustomizer(context));
commandProviderTracker.open();
- commandProcessorTracker = new ServiceTracker<CommandProcessor, ServiceTracker<ConsoleSession,CommandSession>>(context, CommandProcessor.class, new ProcessorCustomizer(context));
+ commandProcessorTracker = new ServiceTracker<>(context, CommandProcessor.class, new ProcessorCustomizer(context));
commandProcessorTracker.open();
- condPermAdminTracker = new ServiceTracker<ConditionalPermissionAdmin, Object>(context, ConditionalPermissionAdmin.class.getName(), null);
+ condPermAdminTracker = new ServiceTracker<>(context, ConditionalPermissionAdmin.class, null);
condPermAdminTracker.open();
// grab permission admin
- permissionAdminTracker = new ServiceTracker<PermissionAdmin, Object>(context, PermissionAdmin.class.getName(), null);
+ permissionAdminTracker = new ServiceTracker<>(context, PermissionAdmin.class, null);
permissionAdminTracker.open();
- startLevelManagerTracker = new ServiceTracker<StartLevel, Object>(context, StartLevel.class.getName(), null);
+ startLevelManagerTracker = new ServiceTracker<>(context, StartLevel.class, null);
startLevelManagerTracker.open();
- packageAdminTracker = new ServiceTracker<PackageAdmin, PackageAdmin>(context, PackageAdmin.class, null);
+ packageAdminTracker = new ServiceTracker<>(context, PackageAdmin.class, null);
packageAdminTracker.open();
equinoxCmdProvider = new EquinoxCommandProvider(context, this);
@@ -252,32 +259,32 @@ public class Activator implements BundleActivator {
}
public StartLevel getStartLevel() {
- return (StartLevel) getServiceFromTracker(startLevelManagerTracker, StartLevel.class.getName());
+ return getServiceFromTracker(startLevelManagerTracker, StartLevel.class);
}
public PermissionAdmin getPermissionAdmin() {
- return (PermissionAdmin) getServiceFromTracker(permissionAdminTracker, PermissionAdmin.class.getName());
+ return getServiceFromTracker(permissionAdminTracker, PermissionAdmin.class);
}
public ConditionalPermissionAdmin getConditionalPermissionAdmin() {
- return (ConditionalPermissionAdmin) getServiceFromTracker(condPermAdminTracker, ConditionalPermissionAdmin.class.getName());
+ return getServiceFromTracker(condPermAdminTracker, ConditionalPermissionAdmin.class);
}
public PackageAdmin getPackageAdmin() {
- return (PackageAdmin) getServiceFromTracker(packageAdminTracker, PackageAdmin.class.getName());
+ return getServiceFromTracker(packageAdminTracker, PackageAdmin.class);
}
- private static Object getServiceFromTracker(ServiceTracker<?, ?> tracker, String serviceClass) {
+ private static <T> T getServiceFromTracker(ServiceTracker<?, T> tracker, Class<T> serviceClass) {
if (tracker == null)
throw new IllegalStateException("Missing service: " + serviceClass);
- Object result = tracker.getService();
+ T result = tracker.getService();
if (result == null)
throw new IllegalStateException("Missing service: " + serviceClass);
return result;
}
Method[] getCommandMethods(Object command) {
- ArrayList<Method> names = new ArrayList<Method>();
+ ArrayList<Method> names = new ArrayList<>();
Class<?> c = command.getClass();
Method[] methods = c.getDeclaredMethods();
for (Method method : methods) {
@@ -294,7 +301,7 @@ public class Activator implements BundleActivator {
}
Dictionary<String, Object> getAttributes(Method[] commandMethods) {
- Dictionary<String, Object> dict = new Hashtable<String, Object>();
+ Dictionary<String, Object> dict = new Hashtable<>();
dict.put("osgi.command.scope", "equinox");
String[] methodNames = new String[commandMethods.length];
for (int i = 0; i < commandMethods.length; i++) {
@@ -306,6 +313,7 @@ public class Activator implements BundleActivator {
return dict;
}
+ @Override
public void stop(BundleContext context) throws Exception {
commandProviderTracker.close();
commandProcessorTracker.close();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java
index d6a7ebef4..c42e12a57 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CommandProviderAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 IBM Corporation, SAP AG.
+ * Copyright (c) 2010, 2017 IBM Corporation, SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,7 +41,7 @@ public class CommandProviderAdapter {
try {
// first argument is the command
Method command = findCommand("_" + args[0]);
- ArrayList<Object> argList = new ArrayList<Object>();
+ ArrayList<Object> argList = new ArrayList<>();
for (int i = 1; i < args.length; i++)
argList.add(args[i]);
return command.invoke(commandProvider, new CustomCommandInterpreter(commandSession, argList));
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java
index 5feaeb436..9f86d4e9f 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/command/adapter/CustomCommandInterpreter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -54,7 +54,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
arguments = args.iterator();
}
- public Object execute(String cmd) {
+ @Override
+public Object execute(String cmd) {
try {
return commandSession.execute(cmd);
} catch (RuntimeException e) {
@@ -64,7 +65,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
}
}
- public String nextArgument() {
+ @Override
+public String nextArgument() {
if (arguments.hasNext()) {
Object next = arguments.next();
return next == null ? null : next.toString();
@@ -77,7 +79,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
*
* @param o the object to be printed
*/
- public void print(Object o) {
+ @Override
+public void print(Object o) {
check4More();
out.print(o);
out.flush();
@@ -86,7 +89,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
/**
* Prints a empty line to the outputstream
*/
- public void println() {
+ @Override
+public void println() {
println(""); //$NON-NLS-1$
}
@@ -94,7 +98,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
* Print a stack trace including nested exceptions.
* @param t The offending exception
*/
- public void printStackTrace(Throwable t) {
+ @Override
+public void printStackTrace(Throwable t) {
t.printStackTrace(out);
Method[] methods = t.getClass().getMethods();
@@ -131,7 +136,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
*
* @param o the object to be printed
*/
- public void println(Object o) {
+ @Override
+public void println(Object o) {
if (o == null) {
return;
}
@@ -160,7 +166,8 @@ public class CustomCommandInterpreter implements CommandInterpreter {
* @param dic the dictionary to print
* @param title the header to print above the key/value pairs
*/
- public void printDictionary(Dictionary<?,?> dic, String title) {
+ @Override
+public void printDictionary(Dictionary<?,?> dic, String title) {
if (dic == null)
return;
@@ -188,25 +195,18 @@ public class CustomCommandInterpreter implements CommandInterpreter {
* @param bundle the bundle containing the resource
* @param resource the resource to print
*/
- public void printBundleResource(Bundle bundle, String resource) {
+ @Override
+public void printBundleResource(Bundle bundle, String resource) {
URL entry = null;
entry = bundle.getEntry(resource);
if (entry != null) {
try {
println(resource);
- InputStream in = entry.openStream();
byte[] buffer = new byte[1024];
int read = 0;
- try {
+ try (InputStream in = entry.openStream()) {
while ((read = in.read(buffer)) != -1)
print(new String(buffer, 0, read));
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
}
} catch (Exception e) {
System.err.println(e);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java
index 2b5f68c6a..4a2d43677 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/CommandsTracker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 SAP AG.
+ * Copyright (c) 2013, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,7 +31,7 @@ public class CommandsTracker {
commandNames = Collections.synchronizedSet(new HashSet<String>());
try {
Filter filter = bundleContext.createFilter(String.format("(&(%s=*)(%s=*))", CommandProcessor.COMMAND_SCOPE, CommandProcessor.COMMAND_FUNCTION));
- commandsTracker = new ServiceTracker<Object, Set<String>>(bundleContext, filter, new CommandsTrackerCustomizer());
+ commandsTracker = new ServiceTracker<>(bundleContext, filter, new CommandsTrackerCustomizer());
commandsTracker.open();
} catch (InvalidSyntaxException e) {
//do nothing;
@@ -40,12 +40,13 @@ public class CommandsTracker {
public Set<String> getCommands() {
synchronized (lock) {
- return new HashSet<String>(commandNames);
+ return new HashSet<>(commandNames);
}
}
class CommandsTrackerCustomizer implements ServiceTrackerCustomizer<Object, Set<String>> {
- public Set<String> addingService(ServiceReference<Object> reference) {
+ @Override
+ public Set<String> addingService(ServiceReference<Object> reference) {
Object scope = reference.getProperty(CommandProcessor.COMMAND_SCOPE);
Object function = reference.getProperty(CommandProcessor.COMMAND_FUNCTION);
@@ -64,10 +65,12 @@ public class CommandsTracker {
return null;
}
+ @Override
public void modifiedService(ServiceReference<Object> reference, Set<String> commandNames) {
// nothing to do
}
+ @Override
public void removedService(ServiceReference<Object> reference, Set<String> commandNames) {
Object scope = reference.getProperty(CommandProcessor.COMMAND_SCOPE);
Object function = reference.getProperty(CommandProcessor.COMMAND_FUNCTION);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java
index 5b79b9aec..56f9bc7df 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/DisconnectCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,7 +36,7 @@ public class DisconnectCommand {
}
public void startService() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] {"disconnect"});
context.registerService(DisconnectCommand.class.getName(), this, props);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java
index bfb11f88a..475cc067a 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2014 IBM Corporation and others.
+ * Copyright (c) 2003, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -65,6 +65,7 @@ import org.osgi.framework.wiring.BundleRevisions;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.framework.wiring.FrameworkWiring;
+import org.osgi.resource.Namespace;
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
@@ -133,7 +134,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
private final static String newline = "\r\n"; //$NON-NLS-1$
/** this list contains the bundles known to be lazily awaiting activation */
- private final List<Bundle> lazyActivation = new ArrayList<Bundle>();
+ private final List<Bundle> lazyActivation = new ArrayList<>();
private Activator activator;
@@ -168,7 +169,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
EquinoxCommandsConverter converter = new EquinoxCommandsConverter(context);
converterReg = context.registerService(Converter.class.getName(), converter, null);
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, functions);
@@ -995,7 +996,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
System.out.print("unwired"); //$NON-NLS-1$
System.out.print(">"); //$NON-NLS-1$
System.out.print("<"); //$NON-NLS-1$
- System.out.print(importReq.getDirectives().get(PackageNamespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
+ System.out.print(importReq.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE));
System.out.println(">"); //$NON-NLS-1$
}
return title;
@@ -1185,7 +1186,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
*/
@Descriptor(ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION)
public List<Dictionary<String, String>> headers(@Descriptor(ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_ARGUMENT_DESCRIPTION) Bundle... bundles) throws Exception {
- ArrayList<Dictionary<String, String>> headers = new ArrayList<Dictionary<String,String>>();
+ ArrayList<Dictionary<String, String>> headers = new ArrayList<>();
if (bundles == null || bundles.length == 0) {
System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR);
@@ -1602,7 +1603,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
} else {
names = symbolicName;
}
- List<Bundle> bundles = new ArrayList<Bundle>();
+ List<Bundle> bundles = new ArrayList<>();
if (names == null) {
bundles.addAll(Arrays.asList(packageAdmin.getBundles(null, null)));
} else {
@@ -1706,14 +1707,14 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
}
}
private Map<String, List<PackageSource>> getPackagesInternal(BundleWiring wiring) {
- Map<String, List<PackageSource>> packages = new TreeMap<String, List<PackageSource>>();
+ Map<String, List<PackageSource>> packages = new TreeMap<>();
// first get the imported packages
List<BundleWire> packageWires = wiring.getRequiredWires(PackageNamespace.PACKAGE_NAMESPACE);
- Set<String> importedPackageNames = new HashSet<String>();
+ Set<String> importedPackageNames = new HashSet<>();
for (BundleWire packageWire : packageWires) {
String packageName = (String) packageWire.getCapability().getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
importedPackageNames.add(packageName);
- List<PackageSource> packageSources = new ArrayList<PackageSource>();
+ List<PackageSource> packageSources = new ArrayList<>();
packageSources.add(new PackageSource(packageWire.getCapability(), packageWire));
packages.put(packageName, packageSources);
}
@@ -1733,7 +1734,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
if (!importedPackageNames.contains(packageName)) {
List<PackageSource> packageSources = packages.get(packageName);
if (packageSources == null) {
- packageSources = new ArrayList<PackageSource>();
+ packageSources = new ArrayList<>();
packages.put(packageName, packageSources);
}
boolean sourceFound = false;
@@ -1750,7 +1751,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
}
// get substituted packages
- Set<String> declaredPackageNames = new HashSet<String>();
+ Set<String> declaredPackageNames = new HashSet<>();
for (BundleCapability declaredPackage : providerWiring.getRevision().getDeclaredCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) {
declaredPackageNames.add((String) declaredPackage.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
}
@@ -1766,7 +1767,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
if (declaredPackageNames.contains(packageName)) {
List<PackageSource> packageSources = packages.get(packageName);
if (packageSources == null) {
- packageSources = new ArrayList<PackageSource>();
+ packageSources = new ArrayList<>();
packages.put(packageName, packageSources);
}
packageSources.add(new PackageSource(packageWire.getCapability(), packageWire));
@@ -1893,7 +1894,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
@Descriptor(ConsoleMsg.CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION)
public void getprop(@Descriptor(ConsoleMsg.CONSOLE_HELP_GETPROP_COMMAND_ARGUMENT_DESCRIPTION) String... propName) throws Exception {
Properties allProperties = System.getProperties();
- Iterator<?> propertyNames = new TreeSet<Object>(allProperties.keySet()).iterator();
+ Iterator<?> propertyNames = new TreeSet<>(allProperties.keySet()).iterator();
while (propertyNames.hasNext()) {
String prop = (String) propertyNames.next();
if (propName == null || propName.length == 0 || prop.startsWith(propName[0])) {
@@ -1905,7 +1906,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
@Descriptor(ConsoleMsg.CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION)
public void diag(@Descriptor(ConsoleMsg.CONSOLE_HELP_DIAG_COMMAND_ARGUMENT_DESCRIPTION) Bundle[] bundles) throws Exception {
if (bundles.length == 0) {
- List<Bundle> unresolved = new ArrayList<Bundle>();
+ List<Bundle> unresolved = new ArrayList<>();
Bundle[] allBundles = context.getBundles();
for (Bundle bundle : allBundles) {
BundleRevision revision = bundle.adapt(BundleRevision.class);
@@ -1942,7 +1943,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
}
private static class DiagReportListener implements ResolverHookFactory {
- private final Collection<BundleRevision> targetTriggers = new ArrayList<BundleRevision>();
+ private final Collection<BundleRevision> targetTriggers = new ArrayList<>();
public DiagReportListener(Bundle[] bundles) {
for (Bundle bundle : bundles) {
BundleRevision revision = bundle.adapt(BundleRevision.class);
@@ -1955,29 +1956,35 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
volatile ResolutionReport report = null;
class DiagResolverHook implements ResolverHook, ResolutionReport.Listener {
+ @Override
public void handleResolutionReport(ResolutionReport report) {
DiagReportListener.this.report = report;
}
+ @Override
public void filterResolvable(Collection<BundleRevision> candidates) {
// nothing
}
+ @Override
public void filterSingletonCollisions(BundleCapability singleton,
Collection<BundleCapability> collisionCandidates) {
// nothing
}
+ @Override
public void filterMatches(BundleRequirement requirement,
Collection<BundleCapability> candidates) {
// nothing
}
+ @Override
public void end() {
// nothing
}
}
+ @Override
public ResolverHook begin(Collection<BundleRevision> triggers) {
if (triggers.containsAll(targetTriggers)) {
return new DiagResolverHook();
@@ -1992,6 +1999,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener {
/**
* This is used to track lazily activated bundles.
*/
+ @Override
public void bundleChanged(BundleEvent event) {
int type = event.getType();
Bundle bundle = event.getBundle();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java
index d3300c449..feab5d83d 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandsConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,17 +32,18 @@ public class EquinoxCommandsConverter implements Converter {
this.context = context;
}
+ @Override
public Object convert(Class<?> desiredType, Object in) throws Exception {
if(desiredType == Bundle[].class) {
if (in instanceof String) {
- if("*".equals((String) in)) {
+ if("*".equals(in)) {
return context.getBundles();
}
} else if (in instanceof List<?>) {
List<?> args = (List<?>) in;
if (checkStringElements(args)) {
try {
- ArrayList<Bundle> bundles = new ArrayList<Bundle>();
+ ArrayList<Bundle> bundles = new ArrayList<>();
for (Object arg : args) {
long id = Long.parseLong((String)arg);
bundles.add(context.getBundle(id));
@@ -124,6 +125,7 @@ public class EquinoxCommandsConverter implements Converter {
return true;
}
+ @Override
public CharSequence format(Object target, int level, Converter escape) throws Exception {
if (target instanceof Dictionary<?, ?>) {
Dictionary<?, ?> dic = (Dictionary<?, ?>) target;
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java
index eef1fa864..61c5bd6e9 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/HelpCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,6 +46,7 @@ public class HelpCommand {
this.context = context;
}
+ @Override
public Set<CommandProvider> addingService(
ServiceReference<CommandProvider> reference) {
if (reference.getProperty("osgi.command.function") != null) {
@@ -58,12 +59,14 @@ public class HelpCommand {
return legacyCommandProviders;
}
+ @Override
public void modifiedService(
ServiceReference<CommandProvider> reference,
Set<CommandProvider> service) {
// nothing to do
}
+ @Override
public void removedService(ServiceReference<CommandProvider> reference,
Set<CommandProvider> providers) {
CommandProvider provider = context.getService(reference);
@@ -74,15 +77,15 @@ public class HelpCommand {
public HelpCommand(BundleContext context) {
this.context = context;
- legacyCommandProviders = new HashSet<CommandProvider>();
- commandProvidersTracker = new ServiceTracker<CommandProvider, Set<CommandProvider>>(context, CommandProvider.class.getName(), new CommandProviderCustomizer(context));
+ legacyCommandProviders = new HashSet<>();
+ commandProvidersTracker = new ServiceTracker<>(context, CommandProvider.class, new CommandProviderCustomizer(context));
commandProvidersTracker.open();
- commandsTrackerTracker = new ServiceTracker<CommandsTracker, CommandsTracker>(context, CommandsTracker.class.getName(), null);
+ commandsTrackerTracker = new ServiceTracker<>(context, CommandsTracker.class, null);
commandsTrackerTracker.open();
}
public void startService() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] {"help"});
@@ -177,7 +180,7 @@ public class HelpCommand {
if (method.getName().equals("_" + command)) {
try {
Method helpMethod = provider.getClass().getMethod("_help", CommandInterpreter.class);
- ArrayList<Object> argsList = new ArrayList<Object>();
+ ArrayList<Object> argsList = new ArrayList<>();
argsList.add(command);
retval = helpMethod.invoke(provider, new CustomCommandInterpreter(session, argsList));
} catch (Exception e) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java
index f17f9827f..e6d2914d2 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/ManCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,7 +25,7 @@ public class ManCommand {
}
public void startService() {
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(CommandProcessor.COMMAND_SCOPE, "equinox");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] {"man"});
context.registerService(ManCommand.class.getName(), this, props);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java
index 3ee1bfe08..6bbc934a3 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -60,7 +60,8 @@ public class ConsoleInputScanner extends Scanner {
this.context = context;
}
- public void scan(int b) throws IOException {
+ @Override
+ public void scan(int b) throws IOException {
b &= 0xFF;
if (isCR) {
isCR = false;
@@ -261,7 +262,7 @@ public class ConsoleInputScanner extends Scanner {
}
protected String[] removeCommonPrefix(String [] names, String commonPrefix){
- ArrayList<String> result = new ArrayList<String>();
+ ArrayList<String> result = new ArrayList<>();
for (String name : names) {
String nameWithoutPrefix = name.substring(commonPrefix.length());
if (nameWithoutPrefix.length() > 0) {
@@ -333,7 +334,8 @@ public class ConsoleInputScanner extends Scanner {
history.reset();
}
- protected void scanEsc(final int b) throws IOException {
+ @Override
+ protected void scanEsc(final int b) throws IOException {
esc += (char) b;
KEYS key = checkEscape(esc);
if (key == KEYS.UNFINISHED) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java
index 73ab4ec32..93f7a69d9 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleInputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,12 +19,13 @@ import java.util.ArrayList;
*/
public class ConsoleInputStream extends InputStream {
- private final ArrayList<byte[]> buffer = new ArrayList<byte[]>();
+ private final ArrayList<byte[]> buffer = new ArrayList<>();
private byte[] current;
private int pos;
private boolean isClosed;
- public synchronized int read() {
+ @Override
+ public synchronized int read() {
while (current == null && buffer.isEmpty() && !isClosed) {
try {
wait();
@@ -108,7 +109,8 @@ public class ConsoleInputStream extends InputStream {
return readCnt;
}*/
- public synchronized int read(byte b[], int off, int len) throws IOException {
+ @Override
+ public synchronized int read(byte b[], int off, int len) throws IOException {
if (len == 0) {
return len;
}
@@ -140,7 +142,8 @@ public class ConsoleInputStream extends InputStream {
return readCnt;
}
- public synchronized void close() throws IOException {
+ @Override
+ public synchronized void close() throws IOException {
isClosed = true;
notifyAll();
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java
index 575342c25..13ec7cb69 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/ConsoleOutputStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -51,7 +51,8 @@ public class ConsoleOutputStream extends OutputStream {
/**
* An implementation of the corresponding abstract method in OutputStream.
*/
- public synchronized void write(int i) throws IOException {
+ @Override
+ public synchronized void write(int i) throws IOException {
if (!queueing) {
if (isEcho) {
@@ -90,7 +91,8 @@ public class ConsoleOutputStream extends OutputStream {
*
* @throws IOException
*/
- public synchronized void flush() throws IOException {
+ @Override
+ public synchronized void flush() throws IOException {
if (pos > 0) {
try {
out.write(buffer, 0, pos);
@@ -122,7 +124,8 @@ public class ConsoleOutputStream extends OutputStream {
*
* @throws IOException
*/
- public void close() throws IOException {
+ @Override
+ public void close() throws IOException {
out.close();
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java
index 38451ad75..7bfe4ee9c 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/InputHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,7 +36,8 @@ public abstract class InputHandler extends Thread {
buffer = new byte[MAX_SIZE];
}
- public void run() {
+ @Override
+ public void run() {
int count;
try {
while ((count = input.read(buffer)) > -1) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java
index 08e6f077e..d5441209f 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/Scanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -51,7 +51,7 @@ public abstract class Scanner {
public Scanner(ConsoleInputStream toShell, OutputStream toTelnet) {
this.toShell = toShell;
this.toTelnet = toTelnet;
- supportedEscapeSequences = new HashMap<String, TerminalTypeMappings> ();
+ supportedEscapeSequences = new HashMap<> ();
supportedEscapeSequences.put("ANSI", new ANSITerminalTypeMappings());
supportedEscapeSequences.put("VT100", new VT100TerminalTypeMappings());
VT220TerminalTypeMappings vtMappings = new VT220TerminalTypeMappings();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java
index 0396c27ec..e92d805e7 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/ANSITerminalTypeMappings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,6 +22,7 @@ public class ANSITerminalTypeMappings extends TerminalTypeMappings {
DEL = 127;
}
+ @Override
public void setKeypadMappings() {
escapesToKey.put("[1~", KEYS.HOME); //$NON-NLS-1$
escapesToKey.put("[4~", KEYS.END); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java
index 53dc2a699..f7298b268 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/terminal/TerminalTypeMappings.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@ public abstract class TerminalTypeMappings {
protected byte DEL;
public TerminalTypeMappings() {
- escapesToKey = new HashMap<String, KEYS>();
+ escapesToKey = new HashMap<>();
escapesToKey.put("[A", KEYS.UP); //$NON-NLS-1$
escapesToKey.put("[B", KEYS.DOWN); //$NON-NLS-1$
escapesToKey.put("[C", KEYS.RIGHT); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java
index f7b496d8b..07009ed3a 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CommandNamesCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,10 +34,11 @@ public class CommandNamesCompleter implements Completer {
public CommandNamesCompleter(BundleContext context, CommandSession session) {
this.session = session;
- commandsTrackerTracker = new ServiceTracker<CommandsTracker, CommandsTracker>(context, CommandsTracker.class.getName(), null);
+ commandsTrackerTracker = new ServiceTracker<>(context, CommandsTracker.class.getName(), null);
commandsTrackerTracker.open();
}
+ @Override
@SuppressWarnings("unchecked")
public Map<String, Integer> getCandidates(String buffer, int cursor) {
CommandsTracker commandsTracker = commandsTrackerTracker.getService();
@@ -54,7 +55,7 @@ public class CommandNamesCompleter implements Completer {
// command names are stored in the session in lower case
String currentToken = CommandLineParser.getCurrentToken(buffer, cursor).toLowerCase();
if(currentToken == null || currentToken.equals("")) {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
if (!currentToken.contains(":")) {
@@ -66,7 +67,7 @@ public class CommandNamesCompleter implements Completer {
}
private Set<String> clearScopes(Set<String> commandNames) {
- Set<String> clearedCommandNames = new HashSet<String>();
+ Set<String> clearedCommandNames = new HashSet<>();
for(String commandName : commandNames) {
clearedCommandNames.add(commandName.substring(commandName.indexOf(":") + 1));
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java
index b2f9e3b08..ea4290774 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/CompletionHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,14 +41,14 @@ public class CompletionHandler {
public CompletionHandler(BundleContext context, CommandSession session) {
this.context = context;
this.session = session;
- completers = new HashSet<Completer>();
+ completers = new HashSet<>();
}
public Map<String, Integer> getCandidates(byte[] buf, int cursor) {
String currentInput = new String(buf);
String currentToken = CommandLineParser.getCurrentToken(currentInput, cursor);
if (currentToken == null){
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
if (currentToken.contains(FILE) == true) {
completers.add(new FileNamesCompleter());
@@ -61,7 +61,7 @@ public class CompletionHandler {
}
}
lookupCustomCompleters();
- Map<String, Integer> candidates = new TreeMap<String, Integer>();
+ Map<String, Integer> candidates = new TreeMap<>();
for (Completer completer : completers) {
candidates.putAll(completer.getCandidates(currentInput, cursor));
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java
index a69ab5e46..aa2c5b4e8 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/FileNamesCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,11 +27,12 @@ import org.eclipse.equinox.console.completion.common.Completer;
public class FileNamesCompleter implements Completer {
private static final String FILE = "file:";
+ @Override
public Map<String, Integer> getCandidates(String buffer, int cursor) {
- Map<String, Integer> result = new HashMap<String, Integer>();
+ Map<String, Integer> result = new HashMap<>();
String currentToken = CommandLineParser.getCurrentToken(buffer, cursor);
if(currentToken == null || currentToken.equals("")) {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
// if current token contains file:, then use URL class to parse the filename
@@ -90,7 +91,7 @@ public class FileNamesCompleter implements Completer {
}
private Map<String, Integer> checkChildren(File parent, String nameToComplete, int cursor, boolean absolute) {
- Map<String, Integer> result = new HashMap<String, Integer>();
+ Map<String, Integer> result = new HashMap<>();
if(parent.exists()) {
File[] children = parent.listFiles();
for(File child : children) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java
index 737237925..ca901535e 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/StringsCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,10 +31,11 @@ public class StringsCompleter implements Completer {
this.isCaseSensitive = isCaseSensitive;
}
+ @Override
public Map<String, Integer> getCandidates(String buffer, int cursor) {
String currentToken = CommandLineParser.getCurrentToken(buffer, cursor);
if (currentToken == null) {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
if (!isCaseSensitive) {
currentToken = currentToken.toLowerCase();
@@ -47,10 +48,10 @@ public class StringsCompleter implements Completer {
// that a variable name is expected; in this case all strings will be
// returned as candidates
if(currentToken.equals("") && buffer.charAt(startIndex - 1) != '$') {
- return new HashMap<String, Integer>();
+ return new HashMap<>();
}
- Map<String, Integer> result = new HashMap<String, Integer>();
+ Map<String, Integer> result = new HashMap<>();
for(String candidate : strings) {
if (isCaseSensitive) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java
index e72277de0..e90940ae7 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/completion/VariableNamesCompleter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 SAP AG
+ * Copyright (c) 2011, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,6 +29,7 @@ public class VariableNamesCompleter implements Completer {
this.session = session;
}
+ @Override
public Map<String, Integer> getCandidates(String buffer, int cursor) {
// CommandSession.get(null) returns the names of all registered varialbes
@SuppressWarnings("unchecked")
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java
index c46811816..852b3f78d 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/NegotiationFinishedCallback.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,6 +24,7 @@ public class NegotiationFinishedCallback implements Callback {
this.telnetConnection = telnetConnection;
}
+ @Override
public void finished() {
telnetConnection.telnetNegotiationFinished();
}
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java
index 8829242f5..fbfe78946 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 SAP AG and others.
+ * Copyright (c) 2010, 2017 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,7 +33,7 @@ public class TelnetCommand {
private String defaultHost = null;
private int defaultPort;
- private List<CommandProcessor> processors = new ArrayList<CommandProcessor>();
+ private List<CommandProcessor> processors = new ArrayList<>();
private final BundleContext context;
private String host = null;
private int port;
@@ -54,7 +54,7 @@ public class TelnetCommand {
processors.add(processor);
this.context = context;
if ("true".equals(context.getProperty(USE_CONFIG_ADMIN_PROP))) {
- Dictionary<String, String> telnetProperties = new Hashtable<String, String>();
+ Dictionary<String, String> telnetProperties = new Hashtable<>();
telnetProperties.put(Constants.SERVICE_PID, TELNET_PID);
try {
synchronized (lock) {
@@ -90,7 +90,7 @@ public class TelnetCommand {
}
public synchronized void startService() {
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ Dictionary<String, Object> properties = new Hashtable<>();
properties.put("osgi.command.scope", "equinox");
properties.put("osgi.command.function", new String[] {"telnet"});
if ((port > 0 || defaultPort > 0) && isEnabled == true) {
@@ -215,6 +215,7 @@ public class TelnetCommand {
class TelnetConfigurator implements ManagedService {
private Dictionary<String, Object> properties;
+ @Override
public synchronized void updated(Dictionary<String, ?> props) throws ConfigurationException {
if (props != null) {
@SuppressWarnings("unchecked")
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java
index cfdf098de..af46bd285 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG and others
+ * Copyright (c) 2010, 2017 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -50,6 +50,7 @@ public class TelnetConnection extends Thread implements Closeable {
callback = new NegotiationFinishedCallback(this);
}
+ @Override
public void run() {
try {
ConsoleInputStream in = new ConsoleInputStream();
@@ -108,6 +109,7 @@ public class TelnetConnection extends Thread implements Closeable {
}
}
+ @Override
public void close() {
try {
this.interrupt();
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java
index 57f9af307..79f189808 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetInputScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG and others
+ * Copyright (c) 2010, 2017 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -39,9 +39,9 @@ public class TelnetInputScanner extends Scanner {
private boolean shouldFinish = false;
private boolean tTypeNegotiationStarted = false;
private int lastRead = -1;
- private ArrayList<Integer> currentTerminalType = new ArrayList<Integer>();
+ private ArrayList<Integer> currentTerminalType = new ArrayList<>();
private ArrayList<Integer> lastTerminalType = null;
- private Set<String> supportedTerminalTypes = new HashSet<String>();
+ private Set<String> supportedTerminalTypes = new HashSet<>();
private Callback callback;
public TelnetInputScanner(ConsoleInputStream toShell, ConsoleOutputStream toTelnet, Callback callback) {
@@ -64,7 +64,8 @@ public class TelnetInputScanner extends Scanner {
supportedTerminalTypes.add("SCO");
}
- public void scan(int b) throws IOException {
+ @Override
+ public void scan(int b) throws IOException {
b &= 0xFF;
if (isEsc) {
@@ -174,7 +175,7 @@ public class TelnetInputScanner extends Scanner {
return;
}
lastTerminalType = currentTerminalType;
- currentTerminalType = new ArrayList<Integer>();
+ currentTerminalType = new ArrayList<>();
if (isLast == true && isMatch == false) {
shouldFinish = true;
sendRequest();
@@ -263,7 +264,8 @@ public class TelnetInputScanner extends Scanner {
toShell.add(new byte[]{BS});
}
- protected void scanEsc(int b) throws IOException {
+ @Override
+ protected void scanEsc(int b) throws IOException {
esc += (char) b;
toShell.add(new byte[]{(byte) b});
KEYS key = checkEscape(esc);
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java
index 9b7dd14b2..0a70dac2b 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/telnet/TelnetServer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG and others
+ * Copyright (c) 2010, 2017 SAP AG and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -35,8 +35,8 @@ public class TelnetServer extends Thread {
private boolean isRunning = true;
private List<CommandProcessor> processors = null;
private BundleContext context;
- private List<Socket> sockets = new ArrayList<Socket>();
- private Map<CommandProcessor, List<TelnetConnection>> processorToConnectionsMapping = new HashMap<CommandProcessor, List<TelnetConnection>>();
+ private List<Socket> sockets = new ArrayList<>();
+ private Map<CommandProcessor, List<TelnetConnection>> processorToConnectionsMapping = new HashMap<>();
public TelnetServer(BundleContext context, List<CommandProcessor> processors, String host, int port) throws IOException {
this.context = context;
@@ -48,6 +48,7 @@ public class TelnetServer extends Thread {
}
}
+ @Override
public void run()
{
try
@@ -60,7 +61,7 @@ public class TelnetServer extends Thread {
TelnetConnection telnetConnection = new TelnetConnection(socket, processor, context);
List<TelnetConnection> telnetConnections = processorToConnectionsMapping.get(processor);
if (telnetConnections == null) {
- telnetConnections = new ArrayList<TelnetConnection>();
+ telnetConnections = new ArrayList<>();
processorToConnectionsMapping.put(processor, telnetConnections);
}
telnetConnections.add(telnetConnection);
@@ -86,7 +87,7 @@ public class TelnetServer extends Thread {
public synchronized void addCommandProcessor(CommandProcessor processor) {
processors.add(processor);
if (!sockets.isEmpty()) {
- List<TelnetConnection> telnetConnections = new ArrayList<TelnetConnection>();
+ List<TelnetConnection> telnetConnections = new ArrayList<>();
for (Socket socket : sockets) {
TelnetConnection telnetConnection = new TelnetConnection(socket, processor, context);
telnetConnections.add(telnetConnection);

Back to the top