Fixed few sonar warnings. 73/46573/5
authorDana Kutenicsova <dana.kutenics@gmail.com>
Tue, 4 Oct 2016 20:02:55 +0000 (22:02 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 7 Oct 2016 22:15:31 +0000 (22:15 +0000)
Removed static imports.

Change-Id: Ife05c6c4fc288c70624880eefbe9c5be8b47b974
Signed-off-by: Dana Kutenicsova <dana.kutenics@gmail.com>
30 files changed:
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/CloseableServiceReferenceReadableRegistry.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionLookupRegistry.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/TransactionStatus.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/ModuleInternalTransactionalInfo.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AttributeHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/factoriesresolver/HierarchicalConfigMBeanFactoriesHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/ServiceReference.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/ServiceReferenceRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/TransactionJMXRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/TransactionModuleJMXRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ExtensibleBundleTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapperTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java

index bf010bb3a603e46d995bc8656a0d5f52ca368f31..87067e83247043f081d02a02a2b2017fd5b0aabc 100644 (file)
@@ -15,6 +15,6 @@ import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry;
  */
 public interface CloseableServiceReferenceReadableRegistry  extends AutoCloseable, ServiceReferenceReadableRegistry {
 
+    @Override
     void close();
-
 }
index b58d2afd24b095dbecb0e2a3681cd216a49758ce..763ed66cb10d947f4ef5aa95d4a6178acf8d009e 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
+import com.google.common.base.Throwables;
 import com.google.common.collect.Maps;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -113,7 +114,8 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
     @GuardedBy("configTransactionLock")
     private List<ModuleFactory> lastListOfFactories = Collections.emptyList();
 
-    @GuardedBy("readableSRRegistryLock") // switched in every 2ndPC
+    // switched in every 2ndPC
+    @GuardedBy("readableSRRegistryLock")
     private CloseableServiceReferenceReadableRegistry readableSRRegistry =
             ServiceReferenceRegistryImpl.createInitialSRLookupRegistry();
 
@@ -207,7 +209,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         // add all factories that disappeared from SR but are still committed
         for (ModuleInternalInfo moduleInternalInfo : currentConfig.getEntries()) {
             String name = moduleInternalInfo.getModuleFactory().getImplementationName();
-            if (allCurrentFactories.containsKey(name) == false) {
+            if (!allCurrentFactories.containsKey(name)) {
                 LOG.trace("Factory {} not found in SR, using reference from previous commit", name);
                 allCurrentFactories.put(name,
                         Maps.immutableEntry(moduleInternalInfo.getModuleFactory(), moduleInternalInfo.getBundleContext()));
@@ -237,11 +239,12 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
 
     /**
      * {@inheritDoc}
+     * @throws ConflictingVersionException
      */
     @Override
     public CommitStatus commitConfig(ObjectName transactionControllerON)
-            throws ConflictingVersionException, ValidationException {
-        if(transactionControllerON == NOOP_TX_NAME || closed.get()) {
+            throws ValidationException, ConflictingVersionException {
+        if(NOOP_TX_NAME.equals(transactionControllerON) || closed.get()) {
             return new CommitStatus(Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
         }
 
@@ -283,15 +286,12 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         // non recoverable from here:
         try {
             return secondPhaseCommit(configTransactionController, commitInfo, configTransactionControllerEntry.getValue());
-        } catch (Error | RuntimeException t) { // some libs throw Errors: e.g.
+            // some libs throw Errors: e.g.
             // javax.xml.ws.spi.FactoryFinder$ConfigurationError
+        } catch (Throwable t) {
             isHealthy = false;
             LOG.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
-            if (t instanceof RuntimeException) {
-                throw (RuntimeException) t;
-            } else {
-                throw (Error) t;
-            }
+            throw Throwables.propagate(t);
         }
     }
 
@@ -303,10 +303,11 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         // (hopefully) runtime beans
         for (DestroyedModule toBeDestroyed : commitInfo
                 .getDestroyedFromPreviousTransactions()) {
-            toBeDestroyed.close(); // closes instance (which should close
+            // closes instance (which should close
             // runtime jmx registrator),
             // also closes osgi registration and ModuleJMXRegistrator
             // registration
+            toBeDestroyed.close();
             currentConfig.remove(toBeDestroyed.getIdentifier());
         }
 
index e426d70df7d28acfdd8ab5860aee962307ca9d15..ad64288ab203a0e9c00d6bbe5964dff33fedf520 100644 (file)
@@ -7,8 +7,7 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.lang.String.format;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -48,6 +47,7 @@ import org.opendaylight.yangtools.concepts.Identifiable;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 /**
  * This is a JMX bean representing current transaction. It contains
  * transaction identifier, unique version and parent version for
@@ -62,7 +62,8 @@ class ConfigTransactionControllerImpl implements
     private final ConfigTransactionLookupRegistry txLookupRegistry;
     private final ObjectName controllerON;
 
-    private final long parentVersion, currentVersion;
+    private final long parentVersion;
+    private final long currentVersion;
     private final HierarchicalConfigMBeanFactoriesHolder factoriesHolder;
     private final DependencyResolverManager dependencyResolverManager;
     private final TransactionStatus transactionStatus;
@@ -129,12 +130,12 @@ class ConfigTransactionControllerImpl implements
         List<ModuleFactory> toBeAdded = new ArrayList<>();
         List<ModuleFactory> toBeRemoved = new ArrayList<>();
         for (ModuleFactory moduleFactory : factoriesHolder.getModuleFactories()) {
-            if (oldSet.contains(moduleFactory) == false) {
+            if (!oldSet.contains(moduleFactory)) {
                 toBeAdded.add(moduleFactory);
             }
         }
         for (ModuleFactory moduleFactory : lastListOfFactories) {
-            if (newSet.contains(moduleFactory) == false) {
+            if (!newSet.contains(moduleFactory)) {
                 toBeRemoved.add(moduleFactory);
             }
         }
@@ -214,7 +215,7 @@ class ConfigTransactionControllerImpl implements
                     moduleIdentifier.getInstanceName(), dependencyResolver,
                     oldConfigBeanInfo.getReadableModule(), bc);
         } catch (Exception e) {
-            throw new IllegalStateException(format(
+            throw new IllegalStateException(String.format(
                     "Error while copying old configuration from %s to %s",
                     oldConfigBeanInfo, moduleFactory), e);
         }
@@ -266,16 +267,16 @@ class ConfigTransactionControllerImpl implements
             throws InstanceAlreadyExistsException {
 
         LOG.debug("Adding module {} to transaction {}", moduleIdentifier, this);
-        if (moduleIdentifier.equals(module.getIdentifier()) == false) {
+        if (!moduleIdentifier.equals(module.getIdentifier())) {
             throw new IllegalStateException("Incorrect name reported by module. Expected "
                     + moduleIdentifier + ", got " + module.getIdentifier());
         }
-        if (dependencyResolver.getIdentifier().equals(moduleIdentifier) == false) {
+        if (!dependencyResolver.getIdentifier().equals(moduleIdentifier)) {
             throw new IllegalStateException("Incorrect name reported by dependency resolver. Expected "
                     + moduleIdentifier + ", got " + dependencyResolver.getIdentifier());
         }
         DynamicMBean writableDynamicWrapper = new DynamicWritableWrapper(
-                module, moduleIdentifier, getTransactionIdentifier(),
+                module, moduleIdentifier, getTransactionIdentifier().getName(),
                 readOnlyAtomicBoolean, transactionsMBeanServer,
                 configMBeanServer);
 
@@ -303,7 +304,7 @@ class ConfigTransactionControllerImpl implements
     private void checkTransactionName(ObjectName objectName) {
         String foundTransactionName = ObjectNameUtil
                 .getTransactionName(objectName);
-        if (getTransactionIdentifier().getName().equals(foundTransactionName) == false) {
+        if (!getTransactionIdentifier().getName().equals(foundTransactionName)) {
             throw new IllegalArgumentException("Wrong transaction name "
                     + objectName);
         }
@@ -314,7 +315,7 @@ class ConfigTransactionControllerImpl implements
         transactionStatus.checkNotAborted();
 
         ModuleInternalTransactionalInfo found = dependencyResolverManager.findModuleInternalTransactionalInfo(moduleIdentifier);
-        if (blankTransaction == false &&
+        if (!blankTransaction &&
                 found.isDefaultBean()) {
             LOG.warn("Warning: removing default bean. This will be forbidden in next version of config-subsystem");
         }
@@ -398,7 +399,8 @@ class ConfigTransactionControllerImpl implements
             validateNoLocks();
         } catch (ValidationException e) {
             LOG.trace("Commit failed on validation");
-            configBeanModificationDisabled.set(false); // recoverable error
+            // recoverable error
+            configBeanModificationDisabled.set(false);
             throw e;
         }
         // errors in this state are not recoverable. modules are not mutable
@@ -414,7 +416,7 @@ class ConfigTransactionControllerImpl implements
     public synchronized List<ModuleIdentifier> secondPhaseCommit() {
         transactionStatus.checkNotAborted();
         transactionStatus.checkCommitStarted();
-        if (configBeanModificationDisabled.get() == false) {
+        if (!configBeanModificationDisabled.get()) {
             throw new IllegalStateException(
                     "Internal error - validateBeforeCommitAndLockTransaction should be called "
                             + "to obtain a lock");
@@ -435,13 +437,13 @@ class ConfigTransactionControllerImpl implements
                 LOG.debug("About to commit {} in transaction {}",
                         moduleIdentifier, getTransactionIdentifier());
                 AutoCloseable instance = module.getInstance();
-                checkNotNull(instance, "Instance is null:{} in transaction {}", moduleIdentifier, getTransactionIdentifier());
+                Preconditions.checkNotNull(instance, "Instance is null:{} in transaction {}", moduleIdentifier, getTransactionIdentifier());
             } catch (Exception e) {
                 LOG.error("Commit failed on {} in transaction {}", moduleIdentifier,
                         getTransactionIdentifier(), e);
                 internalAbort();
                 throw new IllegalStateException(
-                        format("Error - getInstance() failed for %s in transaction %s",
+                        String.format("Error - getInstance() failed for %s in transaction %s",
                                 moduleIdentifier, getTransactionIdentifier()), e);
             }
         }
index a0138b2d9d8c270c2da2cdf1978874409c8e20c1..79bffb49da25873cec2f99d17f19ea3dd25f2351 100644 (file)
@@ -44,7 +44,7 @@ class ConfigTransactionLookupRegistry  implements LookupRegistry, Closeable {
     private void checkTransactionName(ObjectName objectName) {
         String foundTransactionName = ObjectNameUtil
                 .getTransactionName(objectName);
-        if (transactionIdentifier.getName().equals(foundTransactionName) == false) {
+        if (!transactionIdentifier.getName().equals(foundTransactionName)) {
             throw new IllegalArgumentException("Wrong transaction name "
                     + objectName);
         }
@@ -103,6 +103,7 @@ class ConfigTransactionLookupRegistry  implements LookupRegistry, Closeable {
         return txModuleJMXRegistrator;
     }
 
+    @Override
     public void close() {
         transactionJMXRegistrator.close();
     }
index 9882b4662cce2b75519b509135fd17c961e12e9d..20e5fe658411f2b694885496b948217a4e59ef48 100644 (file)
@@ -27,7 +27,7 @@ public class DeadlockMonitor implements AutoCloseable {
     @GuardedBy("this")
     private final Deque<ModuleIdentifierWithNanos> moduleIdentifierWithNanosStack = new LinkedList<>();
     @GuardedBy("this")
-    private ModuleIdentifierWithNanos top = ModuleIdentifierWithNanos.EMPTY;
+    private ModuleIdentifierWithNanos top = ModuleIdentifierWithNanos.empty;
 
     public DeadlockMonitor(TransactionIdentifier transactionIdentifier) {
         this.transactionIdentifier = transactionIdentifier;
@@ -41,7 +41,7 @@ public class DeadlockMonitor implements AutoCloseable {
         if (popping) {
             moduleIdentifierWithNanosStack.pop();
             if (moduleIdentifierWithNanosStack.isEmpty()) {
-                top = ModuleIdentifierWithNanos.EMPTY;
+                top = ModuleIdentifierWithNanos.empty;
             } else {
                 top = moduleIdentifierWithNanosStack.peekLast();
             }
@@ -75,14 +75,15 @@ public class DeadlockMonitor implements AutoCloseable {
 
         @Override
         public void run() {
-            ModuleIdentifierWithNanos old = new ModuleIdentifierWithNanos(); // null moduleId
-            while (this.isInterrupted() == false) {
+            // null moduleId
+            ModuleIdentifierWithNanos old = new ModuleIdentifierWithNanos();
+            while (!this.isInterrupted()) {
                 ModuleIdentifierWithNanos copy;
                 synchronized(this) {
                     copy = new ModuleIdentifierWithNanos(DeadlockMonitor.this.top);
                 }
 
-                if (old.moduleIdentifier == null || old.equals(copy) == false) {
+                if (old.moduleIdentifier == null || !old.equals(copy)) {
                     // started
                     old = copy;
                 } else {
@@ -107,11 +108,8 @@ public class DeadlockMonitor implements AutoCloseable {
         }
     }
 
-
-
-
     private static class ModuleIdentifierWithNanos {
-        private static ModuleIdentifierWithNanos EMPTY = new ModuleIdentifierWithNanos();
+        private static ModuleIdentifierWithNanos empty = new ModuleIdentifierWithNanos();
         @Nullable
         private final ModuleIdentifier moduleIdentifier;
 
index 53e9d47300a104ee73a4da08e01459aa1a87cf86..4e89a653b8bf4453f8d04c36e7690e377387d050 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
-import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import java.util.AbstractMap.SimpleImmutableEntry;
@@ -60,6 +60,54 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     private final boolean writable;
     private final Map<ServiceReference, Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration>> mBeans = new HashMap<>();
 
+    private ServiceReferenceRegistryImpl(final Map<String, ModuleFactory> factories, final LookupRegistry lookupRegistry,
+            final ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory, final boolean writable) {
+        this.factories = factories;
+        this.writable = writable;
+        this.lookupRegistry = lookupRegistry;
+
+        this.serviceReferenceRegistrator = serviceReferenceRegistratorFactory.create();
+
+        Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
+        Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
+        Set<String /* qName */> allQNameSet = new HashSet<>();
+
+        for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
+            if (!entry.getKey().equals(entry.getValue().getImplementationName())) {
+                LOG.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
+                throw new IllegalArgumentException("Possible error in code: Mismatch between supplied and actual name of " + entry);
+            }
+            Set<ServiceInterfaceAnnotation> siAnnotations = InterfacesHelper.getServiceInterfaceAnnotations(entry.getValue());
+            Set<String> qNames = InterfacesHelper.getQNames(siAnnotations);
+            allAnnotations.addAll(siAnnotations);
+            allQNameSet.addAll(qNames);
+            modifiableFactoryNamesToQNames.put(entry.getKey(), qNames);
+        }
+        this.factoryNamesToQNames = ImmutableMap.copyOf(modifiableFactoryNamesToQNames);
+        this.allQNames = ImmutableSet.copyOf(allQNameSet);
+        // fill namespacesToAnnotations
+        Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations = new HashMap<>();
+        Map<String /* service qName*/, ServiceInterfaceAnnotation> modifiableServiceQNamesToAnnotations = new HashMap<>();
+        for (ServiceInterfaceAnnotation sia : allAnnotations) {
+            Map<String, ServiceInterfaceAnnotation> ofNamespace = modifiableNamespacesToAnnotations.get(sia.namespace());
+            if (ofNamespace == null) {
+                ofNamespace = new HashMap<>();
+                modifiableNamespacesToAnnotations.put(sia.namespace(), ofNamespace);
+            }
+            if (ofNamespace.containsKey(sia.localName())) {
+                LOG.error(
+                        "Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
+                        sia.namespace(), sia.localName(), modifiableNamespacesToAnnotations);
+                throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
+            }
+            ofNamespace.put(sia.localName(), sia);
+            modifiableServiceQNamesToAnnotations.put(sia.value(), sia);
+        }
+        this.namespacesToAnnotations = ImmutableMap.copyOf(modifiableNamespacesToAnnotations);
+        this.serviceQNamesToAnnotations = ImmutableMap.copyOf(modifiableServiceQNamesToAnnotations);
+        LOG.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
+    }
+
     /**
      * Static constructor for config registry. Since only transaction can write to this registry, it will
      * return blank state.
@@ -202,56 +250,6 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         return result;
     }
 
-    private ServiceReferenceRegistryImpl(final Map<String, ModuleFactory> factories, final LookupRegistry lookupRegistry,
-                                         final ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory,
-                                         final boolean writable) {
-        this.factories = factories;
-        this.writable = writable;
-        this.lookupRegistry = lookupRegistry;
-
-        this.serviceReferenceRegistrator = serviceReferenceRegistratorFactory.create();
-
-        Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
-        Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
-        Set<String /* qName */> allQNameSet = new HashSet<>();
-
-
-        for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
-            if (entry.getKey().equals(entry.getValue().getImplementationName()) == false) {
-                LOG.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
-                throw new IllegalArgumentException("Possible error in code: Mismatch between supplied and actual name of " + entry);
-            }
-            Set<ServiceInterfaceAnnotation> siAnnotations = InterfacesHelper.getServiceInterfaceAnnotations(entry.getValue());
-            Set<String> qNames = InterfacesHelper.getQNames(siAnnotations);
-            allAnnotations.addAll(siAnnotations);
-            allQNameSet.addAll(qNames);
-            modifiableFactoryNamesToQNames.put(entry.getKey(), qNames);
-        }
-        this.factoryNamesToQNames = ImmutableMap.copyOf(modifiableFactoryNamesToQNames);
-        this.allQNames = ImmutableSet.copyOf(allQNameSet);
-        // fill namespacesToAnnotations
-        Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations =
-                new HashMap<>();
-        Map<String /* service qName*/, ServiceInterfaceAnnotation> modifiableServiceQNamesToAnnotations = new HashMap<>();
-        for (ServiceInterfaceAnnotation sia : allAnnotations) {
-            Map<String, ServiceInterfaceAnnotation> ofNamespace = modifiableNamespacesToAnnotations.get(sia.namespace());
-            if (ofNamespace == null) {
-                ofNamespace = new HashMap<>();
-                modifiableNamespacesToAnnotations.put(sia.namespace(), ofNamespace);
-            }
-            if (ofNamespace.containsKey(sia.localName())) {
-                LOG.error("Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
-                        sia.namespace(), sia.localName(), modifiableNamespacesToAnnotations);
-                throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
-            }
-            ofNamespace.put(sia.localName(), sia);
-            modifiableServiceQNamesToAnnotations.put(sia.value(), sia);
-        }
-        this.namespacesToAnnotations = ImmutableMap.copyOf(modifiableNamespacesToAnnotations);
-        this.serviceQNamesToAnnotations = ImmutableMap.copyOf(modifiableServiceQNamesToAnnotations);
-        LOG.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
-    }
-
     @Override
     public Map<ServiceInterfaceAnnotation, String /* service ref name */> findServiceInterfaces(final ModuleIdentifier moduleIdentifier) {
         Map<ServiceInterfaceAnnotation, String /* service ref name */> result = modulesToServiceRef.get(moduleIdentifier);
@@ -343,7 +341,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     @Override
     public synchronized ObjectName getServiceReference(final String serviceInterfaceQName, final String refName) throws InstanceNotFoundException {
         ServiceReference serviceReference = new ServiceReference(serviceInterfaceQName, refName);
-        if (mBeans.containsKey(serviceReference) == false) {
+        if (!mBeans.containsKey(serviceReference)) {
             throw new InstanceNotFoundException("Cannot find " + serviceReference);
         }
         return getServiceON(serviceReference);
@@ -353,22 +351,21 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     public synchronized void checkServiceReferenceExists(final ObjectName objectName) throws InstanceNotFoundException {
         String actualTransactionName = ObjectNameUtil.getTransactionName(objectName);
         String expectedTransactionName = serviceReferenceRegistrator.getNullableTransactionName();
-        if (writable & actualTransactionName == null || (writable && actualTransactionName.equals(expectedTransactionName) == false)) {
+        if (writable && actualTransactionName == null || (writable && !actualTransactionName.equals(expectedTransactionName))) {
             throw new IllegalArgumentException("Mismatched transaction name in " + objectName);
         }
         String serviceQName = ObjectNameUtil.getServiceQName(objectName);
         String referenceName = ObjectNameUtil.getReferenceName(objectName);
         ServiceReference serviceReference = new ServiceReference(serviceQName, referenceName);
-        if (refNames.containsKey(serviceReference) == false) {
+        if (!refNames.containsKey(serviceReference)) {
             LOG.warn("Cannot find {} in {}", serviceReference, refNames);
             throw new InstanceNotFoundException("Service reference not found:" + objectName);
         }
     }
 
     // writing:
-
     private void assertWritable() {
-        if (writable == false) {
+        if (!writable) {
             throw new IllegalStateException("Cannot write to readable registry");
         }
     }
@@ -389,7 +386,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
                                                          final boolean skipChecks) throws InstanceNotFoundException {
 
         // make sure it is found
-        if (skipChecks == false) {
+        if (!skipChecks) {
             lookupRegistry.checkConfigBeanExists(moduleON);
         }
         String factoryName = ObjectNameUtil.getFactoryName(moduleON);
@@ -404,7 +401,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
             throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + moduleIdentifier.getFactoryName());
         }
         // supplied serviceInterfaceName must exist in this collection
-        if (serviceInterfaceQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
+        if (!serviceInterfaceQNames.contains(serviceReference.getServiceInterfaceQName())) {
             LOG.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceQName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
             throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName() + " within factory " + moduleIdentifier.getFactoryName());
         }
@@ -436,7 +433,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         }
 
         ServiceInterfaceAnnotation annotation = serviceQNamesToAnnotations.get(serviceReference.getServiceInterfaceQName());
-        checkNotNull(annotation, "Possible error in code, cannot find annotation for " + serviceReference);
+        Preconditions.checkNotNull(annotation, "Possible error in code, cannot find annotation for " + serviceReference);
         refNamesToAnnotations.put(annotation, serviceReference.getRefName());
         return result;
     }
@@ -460,7 +457,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         LOG.debug("Removing service reference {} from {}", serviceReference, this);
         assertWritable();
         // is the qName known?
-        if (allQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
+        if (!allQNames.contains(serviceReference.getServiceInterfaceQName())) {
             LOG.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
             throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName());
         }
@@ -504,7 +501,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         for (ServiceReference sr : serviceReferencesLinkingTo) {
             removeServiceReference(sr);
         }
-        return serviceReferencesLinkingTo.isEmpty() == false;
+        return !serviceReferencesLinkingTo.isEmpty();
     }
 
     private Set<ServiceReference> findServiceReferencesLinkingTo(final ObjectName moduleObjectName, final Set<String> serviceInterfaceQNames) {
index f86d6b1d818715481f601a4e366240aae2e5d4a5..af333c3893656da6f70b23f5258127950f691aa3 100644 (file)
@@ -48,32 +48,32 @@ public class TransactionStatus {
     }
 
     public synchronized void checkNotCommitStarted() {
-        if (secondPhaseCommitStarted == true) {
+        if (secondPhaseCommitStarted) {
             throw new IllegalStateException("Commit was triggered");
         }
     }
 
     public synchronized void checkCommitStarted() {
-        if (secondPhaseCommitStarted == false) {
+        if (!secondPhaseCommitStarted) {
             throw new IllegalStateException("Commit was not triggered");
         }
     }
 
     public synchronized void checkNotAborted() {
-        if (aborted == true) {
+        if (aborted) {
             throw new IllegalStateException("Configuration was aborted");
         }
     }
 
     public synchronized void checkNotCommitted() {
-        if (committed == true) {
+        if (committed) {
             throw new IllegalStateException(
                     "Cannot use this method after second phase commit");
         }
     }
 
     public synchronized void checkCommitted() {
-        if (committed == false) {
+        if (!committed) {
             throw new IllegalStateException(
                     "Cannot use this method before second phase commit");
         }
index 10128a2f5532563dc278a38d18d47322b1d4bd09..d667f13ec601e23d6b0cb77447dba63a13c9ec56 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
-import static java.lang.String.format;
-
 import com.google.common.base.Preconditions;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -56,6 +54,7 @@ final class DependencyResolverImpl implements DependencyResolver,
     private final BindingContextProvider bindingContextProvider;
     private final String transactionName;
     private final MBeanServer mBeanServer;
+    private Integer maxDependencyDepth;
 
     DependencyResolverImpl(ModuleIdentifier currentModule,
                            TransactionStatus transactionStatus, ModulesHolder modulesHolder,
@@ -100,8 +99,8 @@ final class DependencyResolverImpl implements DependencyResolver,
         boolean hasTransaction = ObjectNameUtil
                 .getTransactionName(dependentReadOnlyON) != null;
         JmxAttributeValidationException.checkCondition(
-                hasTransaction == false,
-                format("ObjectName should not contain "
+                !hasTransaction,
+                String.format("ObjectName should not contain "
                                 + "transaction name. %s set to %s. ", jmxAttribute,
                         dependentReadOnlyON
             ), jmxAttribute
@@ -116,8 +115,8 @@ final class DependencyResolverImpl implements DependencyResolver,
 
         boolean implementsSI = foundFactory
                 .isModuleImplementingServiceInterface(expectedServiceInterface);
-        if (implementsSI == false) {
-            String message = format(
+        if (!implementsSI) {
+            String message = String.format(
                     "Found module factory does not expose expected service interface. "
                             + "Module name is %s : %s, expected service interface %s, dependent module ON %s , "
                             + "attribute %s",
@@ -158,7 +157,7 @@ final class DependencyResolverImpl implements DependencyResolver,
         }
         AutoCloseable instance = module.getInstance();
         if (instance == null) {
-            String message = format(
+            String message = String.format(
                     "Error while %s resolving instance %s. getInstance() returned null. "
                             + "Expected type %s , attribute %s", name,
                     module.getIdentifier(), expectedType, jmxAttribute
@@ -168,7 +167,7 @@ final class DependencyResolverImpl implements DependencyResolver,
         try {
             return expectedType.cast(instance);
         } catch (ClassCastException e) {
-            String message = format(
+            String message = String.format(
                     "Instance cannot be cast to expected type. Instance class is %s , "
                             + "expected type %s , attribute %s",
                     instance.getClass(), expectedType, jmxAttribute
@@ -240,8 +239,6 @@ final class DependencyResolverImpl implements DependencyResolver,
                 o.getMaxDependencyDepth());
     }
 
-    private Integer maxDependencyDepth;
-
     int getMaxDependencyDepth() {
         if (maxDependencyDepth == null) {
             throw new IllegalStateException("Dependency depth was not computed");
@@ -272,7 +269,7 @@ final class DependencyResolverImpl implements DependencyResolver,
             DependencyResolverImpl dependentDRI = manager
                     .getOrCreate(dependencyName);
             if (chainForDetectingCycles2.contains(dependencyName)) {
-                throw new IllegalStateException(format(
+                throw new IllegalStateException(String.format(
                         "Cycle detected, %s contains %s",
                         chainForDetectingCycles2, dependencyName));
             }
index 231022f34a4b04b38be6a5a33ef6c8690c862c7e..f8906735b6c12aa70ca80307ba2b40941bbb6a9b 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dependencyresolver;
 
-import static com.google.common.base.Preconditions.checkState;
 import com.google.common.base.Preconditions;
 import com.google.common.reflect.AbstractInvocationHandler;
 import com.google.common.reflect.Reflection;
@@ -142,7 +141,7 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
                     return cachedInstance;
                 }
 
-                checkState(deadlockMonitor.isAlive(), "Deadlock monitor is not alive");
+                Preconditions.checkState(deadlockMonitor.isAlive(), "Deadlock monitor is not alive");
                 deadlockMonitor.setCurrentlyInstantiatedModule(moduleIdentifier);
             }
             try {
index 771cddd442ef6210b234472e4d29305e35839a0a..b8d6c26f35363bc3f9c7b29d69b6b2d96ffdb353 100644 (file)
@@ -21,7 +21,8 @@ import org.osgi.framework.BundleContext;
 
 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
     private final ModuleIdentifier name;
-    private final Module proxiedModule, realModule;
+    private final Module proxiedModule;
+    private final Module realModule;
     private final ModuleFactory moduleFactory;
 
     private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
index 0346bdd19c48ff131bde9a99bfcc59bbe05321f5..23a4424a0b028f313147f1e7109a43202464eb04 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.dynamicmbean;
 
-import static java.lang.String.format;
-
 import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -59,14 +57,12 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     private static final class ModuleNotificationListener implements NotificationListener {
         private final ObjectName objectNameInternal;
         private final MBeanServer internalServer;
-        private final ObjectName thisWrapperObjectName;
         private final MBeanServer configMBeanServer;
 
         private ModuleNotificationListener(final ObjectName objectNameInternal, final MBeanServer internalServer,
-                final ObjectName thisWrapperObjectName, final MBeanServer configMBeanServer) {
+                final MBeanServer configMBeanServer) {
             this.objectNameInternal = objectNameInternal;
             this.internalServer = internalServer;
-            this.thisWrapperObjectName = thisWrapperObjectName;
             this.configMBeanServer = configMBeanServer;
         }
 
@@ -74,25 +70,23 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         public void handleNotification(final Notification n, final Object handback) {
             if (n instanceof MBeanServerNotification
                     && n.getType()
-                        .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
-                if (((MBeanServerNotification) n).getMBeanName().equals(
-                        thisWrapperObjectName)) {
-                    try {
-                        internalServer.unregisterMBean(objectNameInternal);
-                        configMBeanServer.removeNotificationListener(
-                                MBeanServerDelegate.DELEGATE_NAME, this);
-                    } catch (MBeanRegistrationException
-                            | ListenerNotFoundException
-                            | InstanceNotFoundException e) {
-                        throw new IllegalStateException(e);
-                    }
+                        .equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)
+                        && ((MBeanServerNotification) n).getMBeanName().equals(
+                        objectNameInternal)) {
+                try {
+                    internalServer.unregisterMBean(objectNameInternal);
+                    configMBeanServer.removeNotificationListener(
+                            MBeanServerDelegate.DELEGATE_NAME, this);
+                } catch (MBeanRegistrationException
+                        | ListenerNotFoundException
+                        | InstanceNotFoundException e) {
+                    throw new IllegalStateException(e);
                 }
             }
         }
     }
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractDynamicWrapper.class);
-    protected final boolean writable;
     protected final Module module;
 
     private final MBeanInfo mbeanInfo;
@@ -106,20 +100,17 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                                   final ObjectName thisWrapperObjectName, final MBeanOperationInfo[] dOperations,
                                   final MBeanServer internalServer, final MBeanServer configMBeanServer) {
 
-        this.writable = writable;
         this.module = module;
         this.moduleIdentifier = moduleIdentifier;
         this.internalServer = internalServer;
         this.objectNameInternal = thisWrapperObjectName;
         // register the actual instance into an mbean server.
-        registerActualModule(module, thisWrapperObjectName, objectNameInternal,
-                internalServer, configMBeanServer);
+        registerActualModule(objectNameInternal, configMBeanServer);
         Set<Class<?>> jmxInterfaces = InterfacesHelper.getMXInterfaces(module
                 .getClass());
-        this.attributeHolderMap = buildMBeanInfo(module, writable,
-                moduleIdentifier, jmxInterfaces, internalServer,
-                objectNameInternal);
-        this.mbeanInfo = generateMBeanInfo(module.getClass().getName(), module,
+        this.attributeHolderMap = buildMBeanInfo(writable,
+                moduleIdentifier, jmxInterfaces, objectNameInternal);
+        this.mbeanInfo = generateMBeanInfo(module,
                 attributeHolderMap, dOperations, jmxInterfaces);
     }
 
@@ -128,12 +119,8 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
      * platform mbean server. Wait until this wrapper gets unregistered, in that
      * case unregister the module and remove listener.
      */
-    private final NotificationListener registerActualModule(final Module module,
-                                                            final ObjectName thisWrapperObjectName,
-                                                            final ObjectName objectNameInternal,
-                                                            final MBeanServer internalServer,
+    private final NotificationListener registerActualModule(final ObjectName objectNameInternal,
                                                             final MBeanServer configMBeanServer) {
-
         try {
             internalServer.registerMBean(module, objectNameInternal);
         } catch (InstanceAlreadyExistsException | MBeanRegistrationException
@@ -142,7 +129,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                     "Error occured during mbean registration with name " + objectNameInternal, e);
         }
 
-        NotificationListener listener = new ModuleNotificationListener(objectNameInternal, internalServer, thisWrapperObjectName, configMBeanServer);
+        NotificationListener listener = new ModuleNotificationListener(objectNameInternal, internalServer, configMBeanServer);
         try {
             configMBeanServer.addNotificationListener(
                     MBeanServerDelegate.DELEGATE_NAME, listener, null, null);
@@ -152,7 +139,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         return listener;
     }
 
-    private static MBeanInfo generateMBeanInfo(final String className, final Module module,
+    private static MBeanInfo generateMBeanInfo(final Module module,
                                                final Map<String, AttributeHolder> attributeHolderMap,
                                                final MBeanOperationInfo[] dOperations, final Set<Class<?>> jmxInterfaces) {
 
@@ -163,7 +150,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         for (AttributeHolder attributeHolder : attributeHolderMap.values()) {
             attributes.add(attributeHolder.toMBeanAttributeInfo());
         }
-        return new MBeanInfo(className, dDescription,
+        return new MBeanInfo(module.getClass().getName(), dDescription,
                 attributes.toArray(new MBeanAttributeInfo[0]), dConstructors,
                 dOperations, new MBeanNotificationInfo[0]);
     }
@@ -180,9 +167,8 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
 
     // inspect all exported interfaces ending with MXBean, extract getters &
     // setters into attribute holder
-    private static Map<String, AttributeHolder> buildMBeanInfo(final Module module,
-                                                               final boolean writable, final ModuleIdentifier moduleIdentifier,
-                                                               final Set<Class<?>> jmxInterfaces, final MBeanServer internalServer,
+    private Map<String, AttributeHolder> buildMBeanInfo(final boolean writable, final ModuleIdentifier moduleIdentifier,
+                                                               final Set<Class<?>> jmxInterfaces,
                                                                final ObjectName internalObjectName) {
 
         // internal variables for describing MBean elements
@@ -205,7 +191,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         for (MBeanAttributeInfo a : internalInfo.getAttributes()) {
             attributeMap.put(a.getName(), a);
         }
-        Map<String, AttributeHolder> attributeHolderMap = new HashMap<>();
+        Map<String, AttributeHolder> attributeHolderMapLocal = new HashMap<>();
         for (Method method : methods) {
 
             if (method.getParameterTypes().length == 1
@@ -229,10 +215,10 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 AttributeHolder attributeHolder = new AttributeHolder(
                         attribName, module, attributeMap.get(attribName)
                             .getType(), writable, ifc, description);
-                attributeHolderMap.put(attribName, attributeHolder);
+                attributeHolderMapLocal.put(attribName, attributeHolder);
             }
         }
-        return attributeHolderMap;
+        return attributeHolderMapLocal;
     }
 
     // DynamicMBean methods
@@ -276,14 +262,14 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     private Object fixDependencyListAttribute(final Object attribute) {
-        if (attribute.getClass().isArray() == false) {
+        if (!attribute.getClass().isArray()) {
             throw new IllegalArgumentException("Unexpected attribute type, should be an array, but was " + attribute.getClass());
         }
 
         for (int i = 0; i < Array.getLength(attribute); i++) {
 
             Object on = Array.get(attribute, i);
-            if (on instanceof ObjectName == false) {
+            if (!(on instanceof ObjectName)) {
                 throw new IllegalArgumentException("Unexpected attribute type, should be an ObjectName, but was " + on.getClass());
             }
             on = fixObjectName((ObjectName) on);
@@ -295,7 +281,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     }
 
     private boolean isDependencyListAttr(final String attributeName, final Object attribute) {
-        if (attributeHolderMap.containsKey(attributeName) == false) {
+        if (!attributeHolderMap.containsKey(attributeName)) {
             return false;
         }
 
@@ -356,7 +342,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
         } else {
             LOG.debug("Operation not found {} ", actionName);
             throw new UnsupportedOperationException(
-                    format("Operation not found on %s. Method invoke is only supported for getInstance and getAttribute(s) "
+                    String.format("Operation not found on %s. Method invoke is only supported for getInstance and getAttribute(s) "
                             + "method, got actionName %s, params %s, signature %s ",
                             moduleIdentifier, actionName, params, signature));
         }
index 7fa70ca10a3d2a3b1c734ff9b97ca1ced7f547e1..6859e4caf3f37dd086a512651146290e8306b53a 100644 (file)
@@ -45,14 +45,15 @@ public class AnnotationsHelper {
                 }
                 // we need to go deeper
                 inspectedClass = inspectedClass.getSuperclass();
+                // no need to go further
             } catch (NoSuchMethodException e) {
-                inspectedClass = Object.class; // no need to go further
+                inspectedClass = Object.class;
             }
         } while (!inspectedClass.equals(Object.class));
 
         // inspect interfaces
         for (Class<?> ifc : inspectedInterfaces) {
-            if (ifc.isInterface() == false) {
+            if (!ifc.isInterface()) {
                 throw new IllegalArgumentException(ifc + " is not an interface");
             }
             try {
@@ -86,10 +87,10 @@ public class AnnotationsHelper {
                 result.add(annotation);
             }
             declaringClass = declaringClass.getSuperclass();
-        } while (declaringClass.equals(Object.class) == false);
+        } while (!declaringClass.equals(Object.class));
         // inspect interfaces
         for (Class<?> ifc : interfaces) {
-            if (ifc.isInterface() == false) {
+            if (!ifc.isInterface()) {
                 throw new IllegalArgumentException(ifc + " is not an interface");
             }
             T annotation = ifc.getAnnotation(annotationType);
index 8618456cf877e44e39c1f55e6a35f9c38bed907b..1a6192290712efedd11ed79fba48dfc413fb4c75 100644 (file)
@@ -30,7 +30,7 @@ class AttributeHolder {
     private final RequireInterface requireInterfaceAnnotation;
     private final String attributeType;
 
-    public static final Set<Class<?>> PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER = new HashSet<>();
+    protected static final Set<Class<?>> PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER = new HashSet<>();
 
     static {
         PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.add(ObjectName.class);
@@ -57,9 +57,8 @@ class AttributeHolder {
     }
 
     public MBeanAttributeInfo toMBeanAttributeInfo() {
-        MBeanAttributeInfo info = new MBeanAttributeInfo(name, attributeType,
+        return new MBeanAttributeInfo(name, attributeType,
                 description, true, true, false);
-        return info;
     }
 
     /**
@@ -120,10 +119,8 @@ class AttributeHolder {
 
         // only allow setX(ObjectName y) or setX(ObjectName[] y) or setX(List<ObjectName> y) to continue
 
-        if (setter.getParameterTypes().length > 1) {
-            return null;
-        }
-        if (PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.contains(setter.getParameterTypes()[0]) == false) {
+        if (setter.getParameterTypes().length > 1 ||
+                !PERMITTED_PARAMETER_TYPES_FOR_DEPENDENCY_SETTER.contains(setter.getParameterTypes()[0])) {
             return null;
         }
 
index 01ebdbdf94d9905999aa536e00152ddd2e79bc47..894858d9d0c860ac2ca5a5f368076056f40240a7 100644 (file)
@@ -12,6 +12,7 @@ import javax.annotation.concurrent.ThreadSafe;
 import javax.management.Attribute;
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
+import javax.management.DynamicMBean;
 import javax.management.InstanceNotFoundException;
 import javax.management.InvalidAttributeValueException;
 import javax.management.MBeanException;
@@ -21,8 +22,8 @@ import javax.management.ObjectName;
 import javax.management.ReflectionException;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.annotations.RequireInterface;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.TransactionIdentifier;
 import org.opendaylight.controller.config.spi.Module;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,11 +54,11 @@ public class DynamicWritableWrapper extends AbstractDynamicWrapper {
 
     public DynamicWritableWrapper(Module module,
                                   ModuleIdentifier moduleIdentifier,
-                                  TransactionIdentifier transactionIdentifier,
+                                  String transactionIdentifier,
                                   ReadOnlyAtomicBoolean configBeanModificationDisabled,
                                   MBeanServer internalServer, MBeanServer configMBeanServer) {
         super(module, true, moduleIdentifier, ObjectNameUtil
-                        .createTransactionModuleON(transactionIdentifier.getName(), moduleIdentifier), getOperations(moduleIdentifier),
+                        .createTransactionModuleON(transactionIdentifier, moduleIdentifier), getOperations(moduleIdentifier),
                 internalServer, configMBeanServer);
         this.configBeanModificationDisabled = configBeanModificationDisabled;
     }
@@ -77,7 +78,7 @@ public class DynamicWritableWrapper extends AbstractDynamicWrapper {
     public synchronized void setAttribute(Attribute attribute)
             throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
         Attribute newAttribute = attribute;
-        if (configBeanModificationDisabled.get() == true) {
+        if (configBeanModificationDisabled.get()) {
             throw new IllegalStateException("Operation is not allowed now");
         }
 
index 65e185e6166cc2b9def63aecbfa61d02425b1bf3..02d1d97677b04064b3890984795807a7d0963ff0 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.factoriesresolver;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -55,7 +54,7 @@ public class HierarchicalConfigMBeanFactoriesHolder {
      * @throws IllegalArgumentException
      *             if factory is not found
      */
-    public ModuleFactory findByModuleName(String moduleName) throws ModuleFactoryNotFoundException {
+    public ModuleFactory findByModuleName(String moduleName) {
         Map.Entry<ModuleFactory, BundleContext> result = moduleNamesToConfigBeanFactories.get(moduleName);
         if (result == null) {
             throw new ModuleFactoryNotFoundException(moduleName);
index 3ad35ac5b5f48d27041244f795a35f32ca781972..3455569ee8a579bc2cdfbe3a9fe401cb897b7317 100644 (file)
@@ -8,7 +8,8 @@
 package org.opendaylight.controller.config.manager.impl.jmx;
 
 public class ServiceReference {
-    private final String serviceInterfaceName, refName;
+    private final String serviceInterfaceName;
+    private final String refName;
 
     public ServiceReference(String serviceInterfaceName, String refName) {
         this.serviceInterfaceName = serviceInterfaceName;
index eafe760ddc1f029d3e9ea471282efd0693a62225..fa0c52699a7b1242a13caec363c43af2483c34d7 100644 (file)
@@ -47,22 +47,24 @@ public interface ServiceReferenceRegistrator extends AutoCloseable {
             this.nullableTransactionName = nullableTransactionName;
         }
 
+        @Override
         public String getNullableTransactionName() {
             return nullableTransactionName;
         }
 
 
+        @Override
         public ServiceReferenceJMXRegistration registerMBean(ServiceReferenceMXBeanImpl object,
                                                              ObjectName on) throws InstanceAlreadyExistsException {
             String actualTransactionName = ObjectNameUtil.getTransactionName(on);
             boolean broken = false;
             broken |= (nullableTransactionName == null) != (actualTransactionName == null);
-            broken |= (nullableTransactionName != null) && nullableTransactionName.equals(actualTransactionName) == false;
+            broken |= (nullableTransactionName != null) && !nullableTransactionName.equals(actualTransactionName);
             if (broken) {
                 throw new IllegalArgumentException("Transaction name mismatch between expected "
                         + nullableTransactionName + ", got " + actualTransactionName + " in " + on);
             }
-            if (ObjectNameUtil.isServiceReference(on) == false) {
+            if (!ObjectNameUtil.isServiceReference(on)) {
                 throw new IllegalArgumentException("Invalid type of " + on);
             }
             return new ServiceReferenceJMXRegistration(currentJMXRegistrator.registerMBean(object, on));
@@ -94,6 +96,7 @@ public interface ServiceReferenceRegistrator extends AutoCloseable {
             this.nullableTransactionName = null;
         }
 
+        @Override
         public ServiceReferenceRegistrator create() {
             return new ServiceReferenceRegistratorImpl(parentRegistrator, nullableTransactionName);
         }
index cf2c553f6b563181d366306b85903f851b3e243b..ceba1c8905d95f048e74fa6528aba37dbcad9cd9 100644 (file)
@@ -64,7 +64,8 @@ public class TransactionJMXRegistrator implements Closeable {
     }
 
     @Override
-    public void close() { // closes also all child TransactionModuleJMXRegistrator instances
+    public void close() {
+        // closes also all child TransactionModuleJMXRegistrator instances
         childJMXRegistrator.close();
     }
 }
index b5c59918f6ed92a4b28614e7911dca899f5d7f1e..81e5ae6e2236dd90f3cc3552cd7d506f56957ccb 100644 (file)
@@ -41,7 +41,7 @@ public class TransactionModuleJMXRegistrator implements Closeable, NestableJMXRe
 
     public TransactionModuleJMXRegistration registerMBean(Object object,
             ObjectName on) throws InstanceAlreadyExistsException {
-        if (transactionName.equals(ObjectNameUtil.getTransactionName(on)) == false) {
+        if (!transactionName.equals(ObjectNameUtil.getTransactionName(on))) {
             throw new IllegalArgumentException("Transaction name mismatch between expected "
                             + transactionName + " " + "and " + on);
         }
@@ -63,6 +63,7 @@ public class TransactionModuleJMXRegistrator implements Closeable, NestableJMXRe
         return transactionName;
     }
 
+    @Override
     public InternalJMXRegistrator createChild() {
         return currentJMXRegistrator.createChild();
     }
index 3d93a9df7dee72bb450af215bd7dea97f24199a5..51f99403148ba7b40301e52b63b391ae98c0134e 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static com.google.common.base.Preconditions.checkState;
+import com.google.common.base.Preconditions;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -40,13 +40,6 @@ public class BeanToOsgiServiceManager {
         return new OsgiRegistration(instance, moduleIdentifier, bundleContext, serviceNamesToAnnotations);
     }
 
-    private static Dictionary<String, String> createProps(String serviceName) {
-        Hashtable<String, String> result = new Hashtable<>();
-        result.put(SERVICE_NAME_OSGI_PROP, serviceName);
-        return result;
-    }
-
-
     public static class OsgiRegistration implements AutoCloseable {
         private static final Logger LOG = LoggerFactory.getLogger(OsgiRegistration.class);
 
@@ -79,7 +72,7 @@ public class BeanToOsgiServiceManager {
                     continue;
                 }
 
-                checkState(requiredInterface.isInstance(instance), instance.getClass().getName() +
+                Preconditions.checkState(requiredInterface.isInstance(instance), instance.getClass().getName() +
                         " instance should implement " + requiredInterface.getName());
                 Dictionary<String, String> propertiesForOsgi = createProps(entry.getValue());
                 ServiceRegistration<?> serviceRegistration = bundleContext
@@ -103,8 +96,8 @@ public class BeanToOsgiServiceManager {
 
         public synchronized void updateRegistrations(Map<ServiceInterfaceAnnotation, String /* service ref name */> newAnnotationMapping,
                                                      BundleContext bundleContext, AutoCloseable newInstance) {
-            boolean notEquals = this.instance != newInstance;
-            notEquals |= newAnnotationMapping.equals(serviceNamesToAnnotations) == false;
+            boolean notEquals = !this.instance.equals(newInstance);
+            notEquals |= !newAnnotationMapping.equals(serviceNamesToAnnotations);
             if (notEquals) {
                 // FIXME: changing from old state to new state can be improved by computing the diff
                 LOG.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier,
@@ -116,5 +109,11 @@ public class BeanToOsgiServiceManager {
                 serviceRegistrations.addAll(newRegs);
             }
         }
+
+        private static Dictionary<String, String> createProps(String serviceName) {
+            Hashtable<String, String> result = new Hashtable<>();
+            result.put(SERVICE_NAME_OSGI_PROP, serviceName);
+            return result;
+        }
     }
 }
index 6c7f38b87dd94d9e64f93c1aef8b18a2246ac73e..a15820556c4a9a76ac45f80ccf89a317df646d53 100644 (file)
@@ -37,14 +37,10 @@ public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<
     private final int maxAttempts;
 
     public BlankTransactionServiceTracker(final ConfigRegistryImpl configRegistry) {
-        this(new BlankTransaction() {
-            @Override
-            public CommitStatus hit()
-                    throws ValidationException, ConflictingVersionException {
-                ObjectName tx = configRegistry.beginConfig(true);
-                return configRegistry.commitConfig(tx);
-            }
-        });
+        this(() -> {
+            ObjectName tx = configRegistry.beginConfig(true);
+            return configRegistry.commitConfig(tx);
+         });
     }
 
     public BlankTransactionServiceTracker(final BlankTransaction blankTransaction) {
@@ -67,7 +63,7 @@ public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<
     }
 
     private void blankTransactionAsync() {
-        txExecutor.execute(() -> { blankTransactionSync(); });
+        txExecutor.execute(this::blankTransactionSync);
     }
 
     void blankTransactionSync() {
index 781debb25668afcce080b71729044f1983ee7f7a..b2f7a6dd20e299190ffd51af6422f668d5e8f316 100644 (file)
@@ -7,16 +7,14 @@
  */
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.registerService;
-import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.wrap;
 import java.lang.management.ManagementFactory;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanServer;
-import org.opendaylight.controller.config.api.ConfigSystemService;
 import org.opendaylight.controller.config.api.ConfigRegistry;
+import org.opendaylight.controller.config.api.ConfigSystemService;
 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
 import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator;
 import org.opendaylight.controller.config.manager.impl.jmx.JMXNotifierConfigRegistry;
@@ -54,7 +52,8 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl
     @Override
     public void start(final BundleContext context) {
         try {
-            ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();// the inner strategy is backed by thread context cl?
+            // the inner strategy is backed by thread context cl?
+            ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
 
             BindingContextProvider bindingContextProvider = new BindingContextProvider();
 
@@ -97,8 +96,8 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl
                     new JMXNotifierConfigRegistry(configRegistry, configMBeanServer);
 
             // register config registry to OSGi
-            AutoCloseable clsReg = registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
-            AutoCloseable configRegReg = registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
+            AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
+            AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
 
             // register config registry to jmx
             ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer);
@@ -124,12 +123,12 @@ public class ConfigManagerActivator implements BundleActivator, SynchronousBundl
                     blankTransactionServiceTracker);
             serviceTracker.open();
 
-            AutoCloseable configMgrReg = registerService(context, this, ConfigSystemService.class);
+            AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, ConfigSystemService.class);
 
             List<AutoCloseable> list = Arrays.asList(bindingContextProvider, clsReg,
-                    wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker,
+                    OsgiRegistrationUtil.wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker,
                     configRegReg, configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications,
-                    wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, configMgrReg);
+                    OsgiRegistrationUtil.wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, configMgrReg);
             autoCloseable = OsgiRegistrationUtil.aggregate(list);
 
             context.addBundleListener(this);
index a0d9122ac6f121e2110455e9cf196103c8ddc245..62215d6626f833f95e47bd4e9066567a3cd91f75 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.config.manager.impl.osgi;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -74,27 +73,18 @@ public final class ExtensibleBundleTracker<T> extends BundleTracker<Future<T>> {
     @Override
     public Future<T> addingBundle(final Bundle bundle, final BundleEvent event) {
         LOG.trace("Submiting AddingBundle for bundle {} and event {} to be processed asynchronously",bundle,event);
-        Future<T> future = eventExecutor.submit(new Callable<T>() {
-            @Override
-            public T call() throws Exception {
-                try {
-                    T primaryTrackerRetVal = primaryTracker.addingBundle(bundle, event);
+        return eventExecutor.submit(() -> {
+            try {
+                T primaryTrackerRetVal = primaryTracker.addingBundle(bundle, event);
 
-                    forEachAdditionalBundle(new BundleStrategy() {
-                        @Override
-                        public void execute(final BundleTrackerCustomizer<?> tracker) {
-                            tracker.addingBundle(bundle, event);
-                        }
-                    });
-                    LOG.trace("AddingBundle for {} and event {} finished successfully",bundle,event);
-                    return primaryTrackerRetVal;
-                } catch (Exception e) {
-                    LOG.error("Failed to add bundle {}", bundle, e);
-                    throw e;
-                }
+                forEachAdditionalBundle(tracker -> tracker.addingBundle(bundle, event));
+                LOG.trace("AddingBundle for {} and event {} finished successfully",bundle,event);
+                return primaryTrackerRetVal;
+            } catch (Exception e) {
+                LOG.error("Failed to add bundle {}", bundle, e);
+                throw e;
             }
         });
-        return future;
     }
 
     @Override
@@ -114,12 +104,7 @@ public final class ExtensibleBundleTracker<T> extends BundleTracker<Future<T>> {
         try {
             LOG.trace("Invoking removedBundle event for {}",bundle);
             primaryTracker.removedBundle(bundle, event, object.get());
-            forEachAdditionalBundle(new BundleStrategy() {
-                @Override
-                public void execute(final BundleTrackerCustomizer<?> tracker) {
-                    tracker.removedBundle(bundle, event, null);
-                }
-            });
+            forEachAdditionalBundle(tracker -> tracker.removedBundle(bundle, event, null));
             LOG.trace("Removed bundle event for {} finished successfully.",bundle);
         } catch (Exception e) {
             LOG.error("Failed to remove bundle {}", bundle, e);
index 83d144d4aeae3adb4160c7bd86c0b2a1588cb8d0..8ca5da282511b88ee4cf5e7ea2887ecfba634b4b 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.impl.osgi;
 
-import static java.lang.String.format;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.io.Resources;
 import java.io.IOException;
@@ -114,6 +113,6 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Boole
     public static String logMessage(String slfMessage, Object... params) {
         LOG.info(slfMessage, params);
         String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
-        return format(formatMessage, params);
+        return String.format(formatMessage, params);
     }
 }
index 7aa74ed18f146b18f02b9605aa59af657ca7e6d7..57740477a1f6c6ec643d94776e7e62ef6e961753 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.controller.config.manager.impl.osgi.mapping;
 
-import static java.lang.String.format;
 import com.google.common.io.Resources;
 import java.io.IOException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import java.nio.charset.StandardCharsets;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
@@ -73,8 +73,8 @@ public final class ModuleInfoBundleTracker implements AutoCloseable,
     public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
         URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
         LOG.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
-        if(resource==null) {
-            return null;
+        if(resource == null) {
+            return Collections.emptyList();
         }
         List<ObjectRegistration<YangModuleInfo>> registrations = new LinkedList<>();
 
@@ -121,7 +121,7 @@ public final class ModuleInfoBundleTracker implements AutoCloseable,
         String errorMessage;
         Class<?> clazz = loadClass(moduleInfoClass, bundle);
 
-        if (YangModelBindingProvider.class.isAssignableFrom(clazz) == false) {
+        if (!YangModelBindingProvider.class.isAssignableFrom(clazz)) {
             errorMessage = logMessage("Class {} does not implement {} in bundle {}", clazz, YangModelBindingProvider.class, bundle);
             throw new IllegalStateException(errorMessage);
         }
@@ -157,6 +157,6 @@ public final class ModuleInfoBundleTracker implements AutoCloseable,
     public static String logMessage(String slfMessage, Object... params) {
         LOG.info(slfMessage, params);
         String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
-        return format(formatMessage, params);
+        return String.format(formatMessage, params);
     }
 }
index 8001169771e6a77a3dc9e2544cab9c91e9fc5cdb..59c4d9fa3d5851cb71fd0f352bc0aab4a070740e 100644 (file)
@@ -59,7 +59,8 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
                 final Dictionary<String, Object> props = new Hashtable<>();
                 props.put(BindingRuntimeContext.class.getName(), bindingContextProvider.getBindingContext());
                 props.put(SchemaSourceProvider.class.getName(), sourceProvider);
-                osgiReg.setProperties(props); // send modifiedService event
+                // send modifiedService event
+                osgiReg.setProperties(props);
             } catch (RuntimeException e) {
                 // The ModuleInfoBackedContext throws a RuntimeException if it can't create the schema context.
                 LOG.warn("Error updating the BindingContextProvider", e);
@@ -70,8 +71,7 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
     @Override
     public ObjectRegistration<YangModuleInfo> registerModuleInfo(final YangModuleInfo yangModuleInfo) {
         ObjectRegistration<YangModuleInfo> yangModuleInfoObjectRegistration = moduleInfoRegistry.registerModuleInfo(yangModuleInfo);
-        ObjectRegistrationWrapper wrapper = new ObjectRegistrationWrapper(yangModuleInfoObjectRegistration);
-        return wrapper;
+        return new ObjectRegistrationWrapper(yangModuleInfoObjectRegistration);
     }
 
     @Override
@@ -98,7 +98,8 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto
         @Override
         public void close() throws Exception {
             inner.close();
-            updateService();// send modify event when a bundle disappears
+            // send modify event when a bundle disappears
+            updateService();
         }
 
         @Override
index f4d732c65c262cb65fe29f09e2ed954e5f1f2995..8538e3f84d62daf7e216352808743c1bfe2c78f9 100644 (file)
@@ -31,7 +31,7 @@ public final class InterfacesHelper {
         }
         // getInterfaces gets interfaces implemented directly by this class
         Set<Class<?>> toBeInspected = new HashSet<>();
-        while (clazz.equals(Object.class) == false) {
+        while (!clazz.equals(Object.class)) {
             toBeInspected.addAll(Arrays.asList(clazz.getInterfaces()));
             // get parent class
             clazz = clazz.getSuperclass();
@@ -48,7 +48,7 @@ public final class InterfacesHelper {
             Iterator<Class<?>> iterator = interfaces.iterator();
             Class<?> ifc = iterator.next();
             iterator.remove();
-            if (ifc.isInterface() == false)  {
+            if (!ifc.isInterface())  {
                 throw new IllegalArgumentException(ifc + " should be an interface");
             }
             interfaces.addAll(Arrays.asList(ifc.getInterfaces()));
@@ -97,7 +97,7 @@ public final class InterfacesHelper {
 
         Set<Class<? extends AbstractServiceInterface>> foundGeneratedSIClasses = new HashSet<>();
         for (Class<?> clazz : getAllInterfaces(configBeanClass)) {
-            if (AbstractServiceInterface.class.isAssignableFrom(clazz) && AbstractServiceInterface.class.equals(clazz) == false) {
+            if (AbstractServiceInterface.class.isAssignableFrom(clazz) && !AbstractServiceInterface.class.equals(clazz)) {
                 foundGeneratedSIClasses.add((Class<? extends AbstractServiceInterface>) clazz);
             }
         }
@@ -155,7 +155,7 @@ public final class InterfacesHelper {
         Set<Class<? extends AbstractServiceInterface>> result = new HashSet<>();
         for(Class<?> ifc: allInterfaces){
             if (AbstractServiceInterface.class.isAssignableFrom(ifc) &&
-                    ifc.equals(AbstractServiceInterface.class) == false) {
+                    !ifc.equals(AbstractServiceInterface.class)) {
                 result.add((Class<? extends AbstractServiceInterface>) ifc);
             }
 
index fe8e30ee9ad2816a63f38365fb39c032193dd798..7c02019544977b8e33d4ecd08ad91d2ab6af3642 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.config.manager.impl.util;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.ListIterator;
@@ -40,32 +39,17 @@ public class OsgiRegistrationUtil {
 
     public static AutoCloseable wrap(final ServiceRegistration<?> reg) {
         checkNotNull(reg);
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                reg.unregister();
-            }
-        };
+        return reg::unregister;
     }
 
     public static AutoCloseable wrap(final BundleTracker<?> bundleTracker) {
         checkNotNull(bundleTracker);
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                bundleTracker.close();
-            }
-        };
+        return bundleTracker::close;
     }
 
     public static AutoCloseable wrap(final ServiceTracker<?, ?> serviceTracker) {
         checkNotNull(serviceTracker);
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                serviceTracker.close();
-            }
-        };
+        return serviceTracker::close;
     }
 
     /**
@@ -74,26 +58,23 @@ public class OsgiRegistrationUtil {
     public static AutoCloseable aggregate(final List<? extends AutoCloseable> list) {
         checkNotNull(list);
 
-        return new AutoCloseable() {
-            @Override
-            public void close() throws Exception {
-                Exception firstException = null;
-                for (ListIterator<? extends AutoCloseable> it = list.listIterator(list.size()); it.hasPrevious();) {
-                    AutoCloseable ac = it.previous();
-                    try {
-                        ac.close();
-                    } catch (Exception e) {
-                        LOG.warn("Exception while closing {}", ac, e);
-                        if (firstException == null) {
-                            firstException = e;
-                        } else {
-                            firstException.addSuppressed(e);
-                        }
+        return () -> {
+            Exception firstException = null;
+            for (ListIterator<? extends AutoCloseable> it = list.listIterator(list.size()); it.hasPrevious();) {
+                AutoCloseable ac = it.previous();
+                try {
+                    ac.close();
+                } catch (Exception e) {
+                    LOG.warn("Exception while closing {}", ac, e);
+                    if (firstException == null) {
+                        firstException = e;
+                    } else {
+                        firstException.addSuppressed(e);
                     }
                 }
-                if (firstException != null) {
-                    throw firstException;
-                }
+            }
+            if (firstException != null) {
+                throw firstException;
             }
         };
     }
index d453f1e7798eee1aeb848ac9bd23ad98625f7bf4..bd8211377f816991b2c73d1c3676f24f4cc94378 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.config.manager.impl.dynamicmbean;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.management.Attribute;
 import javax.management.AttributeList;
@@ -20,7 +19,6 @@ import javax.management.ObjectName;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.TransactionIdentifier;
 import org.opendaylight.controller.config.manager.impl.dynamicmbean.ReadOnlyAtomicBoolean.ReadOnlyAtomicBooleanImpl;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModule;
@@ -38,7 +36,7 @@ public class DynamicWritableWrapperTest extends AbstractDynamicWrapperTest {
     protected AbstractDynamicWrapper getDynamicWrapper(Module module,
             ModuleIdentifier moduleIdentifier) {
         return new DynamicWritableWrapper(module, moduleIdentifier,
-                new TransactionIdentifier("transaction-1"),
+                "transaction-1",
                 readOnlyAtomicBoolean, MBeanServerFactory.createMBeanServer(),
                 platformMBeanServer);
     }
index fd8c8d1df0c7b1b250b0454f91c36b12d0cd1f25..7b4a9f335a2b2b110f57da07ff7adb8591e8f05c 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import java.util.Map;
 import javax.management.ObjectName;
 import org.junit.After;
@@ -33,7 +32,6 @@ import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
 public class DependentWiringTest extends AbstractParallelAPSPTest {
     private final String fixed1 = "fixed1";
-    private final String apsp1 = "apsp-parallel";
 
     @Before
     public void setUp() {