From: Stephen Kitt Date: Fri, 12 May 2017 16:04:17 +0000 (+0200) Subject: shutdown-impl: final parameters X-Git-Tag: release/nitrogen~259 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=1417bcd892b1dc9a4d68c9562d91eee8320de38f shutdown-impl: final parameters This automatically-generated patch flags all appropriate parameters as final (including caught exceptions). Change-Id: I2c2aa1163511c2bd2776e1105732df73669328f3 Signed-off-by: Stephen Kitt --- diff --git a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModule.java b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModule.java index e3ae30db74..57efe52827 100644 --- a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModule.java +++ b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModule.java @@ -24,34 +24,34 @@ import org.osgi.framework.Bundle; public final class ShutdownModule extends AbstractShutdownModule { private final Bundle systemBundle; - public ShutdownModule(ModuleIdentifier identifier, Bundle systemBundle) { + public ShutdownModule(final ModuleIdentifier identifier, final Bundle systemBundle) { super(identifier, null); singletonCheck(identifier); this.systemBundle = systemBundle; } - public ShutdownModule(ModuleIdentifier identifier, ShutdownModule oldModule, java.lang.AutoCloseable oldInstance, - Bundle systemBundle) { + public ShutdownModule(final ModuleIdentifier identifier, final ShutdownModule oldModule, final java.lang.AutoCloseable oldInstance, + final Bundle systemBundle) { super(identifier, null, oldModule, oldInstance); singletonCheck(identifier); this.systemBundle = systemBundle; } - private static void singletonCheck(ModuleIdentifier identifier) { + private static void singletonCheck(final ModuleIdentifier identifier) { if (AbstractShutdownModuleFactory.NAME.equals(identifier.getInstanceName()) == false) { throw new IllegalArgumentException("Singleton enforcement failed. Expected instance name " + AbstractShutdownModuleFactory.NAME); } } @Deprecated // needed for generated code - public ShutdownModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver, ShutdownModule oldModule, - AutoCloseable oldInstance) { + public ShutdownModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, final ShutdownModule oldModule, + final AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); throw new UnsupportedOperationException(); } @Deprecated // needed for generated code - public ShutdownModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) { + public ShutdownModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); throw new UnsupportedOperationException(); } diff --git a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModuleFactory.java b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModuleFactory.java index 1994e21a6d..de7ed0fa66 100644 --- a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModuleFactory.java +++ b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModuleFactory.java @@ -17,22 +17,22 @@ import org.osgi.framework.BundleContext; public class ShutdownModuleFactory extends AbstractShutdownModuleFactory { - public ShutdownModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, - ShutdownModule oldModule, AutoCloseable oldInstance, - BundleContext bundleContext) { + public ShutdownModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver, + final ShutdownModule oldModule, final AutoCloseable oldInstance, + final BundleContext bundleContext) { Bundle systemBundle = bundleContext.getBundle(0); return new ShutdownModule(new ModuleIdentifier(NAME, instanceName), oldModule, oldInstance, systemBundle); } - public ShutdownModule instantiateModule(String instanceName, DependencyResolver dependencyResolver, - BundleContext bundleContext) { + public ShutdownModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver, + final BundleContext bundleContext) { Bundle systemBundle = bundleContext.getBundle(0); return new ShutdownModule(new ModuleIdentifier(NAME, instanceName), systemBundle); } @Override - public Set getDefaultModules(DependencyResolverFactory dependencyResolverFactory, BundleContext bundleContext) { + public Set getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) { ModuleIdentifier id = new ModuleIdentifier(NAME, NAME); DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(id); ShutdownModule shutdownModule = instantiateModule(NAME, dependencyResolver, bundleContext); diff --git a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownServiceImpl.java b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownServiceImpl.java index 7d97fcd964..74634dd157 100644 --- a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownServiceImpl.java +++ b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownServiceImpl.java @@ -20,8 +20,8 @@ public class ShutdownServiceImpl implements ShutdownService, AutoCloseable { private final ShutdownService impl; private final ShutdownRuntimeRegistration registration; - public ShutdownServiceImpl(String secret, Bundle systemBundle, - ShutdownRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) { + public ShutdownServiceImpl(final String secret, final Bundle systemBundle, + final ShutdownRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) { if (secret == null) { throw new IllegalArgumentException("Secret cannot be null"); } @@ -30,7 +30,7 @@ public class ShutdownServiceImpl implements ShutdownService, AutoCloseable { } @Override - public void shutdown(String inputSecret, Long maxWaitTime, Optional reason) { + public void shutdown(final String inputSecret, final Long maxWaitTime, final Optional reason) { impl.shutdown(inputSecret, maxWaitTime, reason); } @@ -45,17 +45,17 @@ class Impl implements ShutdownService { private final String secret; private final Bundle systemBundle; - Impl(String secret, Bundle systemBundle) { + Impl(final String secret, final Bundle systemBundle) { this.secret = secret; this.systemBundle = systemBundle; } @Override - public void shutdown(String inputSecret, Long maxWaitTime, Optional reason) { + public void shutdown(final String inputSecret, final Long maxWaitTime, final Optional reason) { LOG.warn("Shutdown issued with secret {} and reason {}", inputSecret, reason); try { Thread.sleep(1000); // prevent brute force attack - } catch (InterruptedException e) { + } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.warn("Shutdown process interrupted", e); } @@ -83,7 +83,7 @@ class StopSystemBundleThread extends Thread { private static final Logger LOG = LoggerFactory.getLogger(StopSystemBundleThread.class); private final Bundle systemBundle; - StopSystemBundleThread(Bundle systemBundle) { + StopSystemBundleThread(final Bundle systemBundle) { super("stop-system-bundle"); this.systemBundle = systemBundle; } @@ -95,9 +95,9 @@ class StopSystemBundleThread extends Thread { Thread.sleep(1000); LOG.debug("Stopping system bundle"); systemBundle.stop(); - } catch (BundleException e) { + } catch (final BundleException e) { LOG.warn("Can not stop OSGi server", e); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { LOG.warn("Shutdown process interrupted", e); } } @@ -106,7 +106,7 @@ class StopSystemBundleThread extends Thread { class CallSystemExitThread extends Thread { private static final Logger LOG = LoggerFactory.getLogger(CallSystemExitThread.class); private final long maxWaitTime; - CallSystemExitThread(long maxWaitTime) { + CallSystemExitThread(final long maxWaitTime) { super("call-system-exit-daemon"); setDaemon(true); if (maxWaitTime <= 0){ @@ -137,7 +137,7 @@ class CallSystemExitThread extends Thread { } LOG.warn("Thread dump:{}", sb); System.exit(1); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { LOG.warn("Interrupted, not going to call System.exit(1)"); } } @@ -147,12 +147,12 @@ class CallSystemExitThread extends Thread { class MXBeanImpl implements ShutdownRuntimeMXBean { private final ShutdownService impl; - MXBeanImpl(ShutdownService impl) { + MXBeanImpl(final ShutdownService impl) { this.impl = impl; } @Override - public void shutdown(String inputSecret, Long maxWaitTime, String nullableReason) { + public void shutdown(final String inputSecret, final Long maxWaitTime, final String nullableReason) { Optional optionalReason; if (nullableReason == null) { optionalReason = Optional.absent(); diff --git a/opendaylight/config/shutdown-impl/src/test/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownTest.java b/opendaylight/config/shutdown-impl/src/test/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownTest.java index 358586f634..5dd856a605 100644 --- a/opendaylight/config/shutdown-impl/src/test/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownTest.java +++ b/opendaylight/config/shutdown-impl/src/test/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownTest.java @@ -62,7 +62,7 @@ public class ShutdownTest extends AbstractConfigTest { try { transaction.createModule(NAME, "foo"); fail(); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { assertEquals("Singleton enforcement failed. Expected instance name shutdown", e.getMessage()); } } @@ -77,7 +77,7 @@ public class ShutdownTest extends AbstractConfigTest { try { runtime.shutdown("foo", 60000L, null); fail(); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { assertEquals("Invalid secret", e.getMessage()); } runtime.shutdown("", 60000L, null); @@ -92,7 +92,7 @@ public class ShutdownTest extends AbstractConfigTest { shutdownViaRuntimeJMX(secret); } - private void setSecret(String secret) throws InstanceNotFoundException, ValidationException, ConflictingVersionException { + private void setSecret(final String secret) throws InstanceNotFoundException, ValidationException, ConflictingVersionException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName on = transaction.lookupConfigBean(NAME, NAME); ShutdownModuleMXBean proxy = transaction.newMXBeanProxy(on, ShutdownModuleMXBean.class); @@ -107,18 +107,18 @@ public class ShutdownTest extends AbstractConfigTest { ShutdownRuntimeMXBean runtime = JMX.newMXBeanProxy(platformMBeanServer, runtimeON, ShutdownRuntimeMXBean.class); runtime.shutdown("foo", 60000L, null); fail(); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { assertEquals("Invalid secret", e.getMessage()); } } - private void shutdownViaRuntimeJMX(String secret) throws Exception { + private void shutdownViaRuntimeJMX(final String secret) throws Exception { // test JMX rpc ShutdownRuntimeMXBean runtime = JMX.newMXBeanProxy(platformMBeanServer, runtimeON, ShutdownRuntimeMXBean.class); try { runtime.shutdown("", 60000L, null); fail(); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { assertEquals("Invalid secret", e.getMessage()); } runtime.shutdown(secret, 60000L, null);