BUG-692 Fix major issues reported by sonar for netconf subsystem 90/11290/2
authorMaros Marsalek <mmarsale@cisco.com>
Wed, 17 Sep 2014 14:11:14 +0000 (16:11 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Thu, 18 Sep 2014 09:14:41 +0000 (09:14 +0000)
Change-Id: I2f7cd479a773b7c3edc111c45add8ab5510fb47f
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
18 files changed:
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/SimpleIdentityRefAttributeReadingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Config.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ServiceRegistryWrapper.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Services.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/transactions/TransactionProvider.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusherImpl.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfMonitoringServiceImpl.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/osgi/NetconfOperationRouterImpl.java
opendaylight/netconf/netconf-monitoring/src/main/java/org/opendaylight/controller/netconf/monitoring/xml/model/MonitoringSchema.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/osgi/NetconfSSHActivator.java
opendaylight/netconf/netconf-usermanager/src/main/java/org/opendaylight/controller/netconf/auth/usermanager/AuthProviderImpl.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperation.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageUtil.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java

index 8720c654c61f993f09d6503305fdc471d4065a94..1d12292edb2624ee12b7d1c469c44102ab617dfc 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attri
 
 import com.google.common.base.Preconditions;
 
+import com.google.common.base.Strings;
 import java.util.List;
 import java.util.Map;
 
@@ -52,7 +53,7 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
     public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) throws NetconfDocumentedException {
         String serviceName = typeElement.getTextContent();
         // FIXME: comparing Entry with String:
-        Preconditions.checkState(!prefixNamespace.equals(""), "Service %s value not prefixed with namespace",
+        Preconditions.checkState(!Strings.isNullOrEmpty(prefixNamespace.getKey()), "Service %s value not prefixed with namespace",
                 XmlNetconfConstants.TYPE_KEY);
         String prefix = prefixNamespace.getKey() + PREFIX_SEPARATOR;
         Preconditions.checkState(serviceName.startsWith(prefix),
index 8e7ba708c6cea71ba46400f99fb765a2113bf762..94a90a782ebbd82e5a35643d27e15f9607248537 100644 (file)
@@ -47,11 +47,11 @@ public class SimpleIdentityRefAttributeReadingStrategy extends SimpleAttributeRe
         Date revision = null;
         Map<Date, EditConfig.IdentityMapping> revisions = identityMap.get(namespace);
         if(revisions.keySet().size() > 1) {
-            for (Date date : revisions.keySet()) {
-                if(revisions.get(date).containsIdName(localName)) {
+            for (Map.Entry<Date, EditConfig.IdentityMapping> revisionToIdentityEntry : revisions.entrySet()) {
+                if(revisionToIdentityEntry.getValue().containsIdName(localName)) {
                     Preconditions.checkState(revision == null, "Duplicate identity %s, in namespace %s, with revisions: %s, %s detected. Cannot map attribute",
-                            localName, namespace, revision, date);
-                    revision = date;
+                            localName, namespace, revision, revisionToIdentityEntry.getKey());
+                    revision = revisionToIdentityEntry.getKey();
                 }
             }
         } else {
index 5d41b784f5cdaa4ff264774b05069ad6e83f3ff3..773e4ee933c147d6206394b8da51fd4f8094358f 100644 (file)
@@ -60,11 +60,11 @@ public class Config {
 
         Map<String, Map<String, Collection<ObjectName>>> retVal = Maps.newLinkedHashMap();
 
-        for (String namespace : configs.keySet()) {
+        for (Entry<String, Map<String, ModuleConfig>> namespaceToModuleToConfigEntry : configs.entrySet()) {
 
             Map<String, Collection<ObjectName>> innerRetVal = Maps.newHashMap();
 
-            for (Entry<String, ModuleConfig> mbeEntry : configs.get(namespace).entrySet()) {
+            for (Entry<String, ModuleConfig> mbeEntry : namespaceToModuleToConfigEntry.getValue().entrySet()) {
 
                 String moduleName = mbeEntry.getKey();
                 Collection<ObjectName> instances = moduleToInstances.get(moduleName);
@@ -80,7 +80,7 @@ public class Config {
 
             }
 
-            retVal.put(namespace, innerRetVal);
+            retVal.put(namespaceToModuleToConfigEntry.getKey(), innerRetVal);
         }
         return retVal;
     }
@@ -107,18 +107,18 @@ public class Config {
 
         Element modulesElement = XmlUtil.createElement(document, XmlNetconfConstants.MODULES_KEY, Optional.of(XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG));
         dataElement.appendChild(modulesElement);
-        for (String moduleNamespace : moduleToInstances.keySet()) {
-            for (Entry<String, Collection<ObjectName>> moduleMappingEntry : moduleToInstances.get(moduleNamespace)
+        for (Entry<String, Map<String, Collection<ObjectName>>> moduleToInstanceEntry : moduleToInstances.entrySet()) {
+            for (Entry<String, Collection<ObjectName>> moduleMappingEntry : moduleToInstanceEntry.getValue()
                     .entrySet()) {
 
-                ModuleConfig mapping = moduleConfigs.get(moduleNamespace).get(moduleMappingEntry.getKey());
+                ModuleConfig mapping = moduleConfigs.get(moduleToInstanceEntry.getKey()).get(moduleMappingEntry.getKey());
 
                 if (moduleMappingEntry.getValue().isEmpty()) {
                     continue;
                 }
 
                 for (ObjectName objectName : moduleMappingEntry.getValue()) {
-                    modulesElement.appendChild(mapping.toXml(objectName, document, moduleNamespace));
+                    modulesElement.appendChild(mapping.toXml(objectName, document, moduleToInstanceEntry.getKey()));
                 }
 
             }
index 2b363ea153960eeb98754855ffa54473e43fad14..8c2c74f2ac58d1c2144a1e8194cb46e15eb279b9 100644 (file)
@@ -24,7 +24,6 @@ public class ServiceRegistryWrapper {
         this.configServiceRefRegistry = configServiceRefRegistry;
     }
 
-
     public ObjectName getByServiceAndRefName(String namespace, String serviceName, String refName) {
         Map<String, Map<String, String>> serviceNameToRefNameToInstance = getMappedServices().get(namespace);
 
@@ -61,13 +60,13 @@ public class ServiceRegistryWrapper {
         Map<String, Map<String, Map<String, String>>> retVal = Maps.newHashMap();
 
         Map<String, Map<String, ObjectName>> serviceMapping = configServiceRefRegistry.getServiceMapping();
-        for (String serviceQName : serviceMapping.keySet()){
-            for (String refName : serviceMapping.get(serviceQName).keySet()) {
+        for (Map.Entry<String, Map<String, ObjectName>> qNameToRefNameEntry : serviceMapping.entrySet()){
+            for (String refName : qNameToRefNameEntry.getValue().keySet()) {
 
-                ObjectName on = serviceMapping.get(serviceQName).get(refName);
+                ObjectName on = qNameToRefNameEntry.getValue().get(refName);
                 Services.ServiceInstance si = Services.ServiceInstance.fromObjectName(on);
 
-                QName qname = QName.create(serviceQName);
+                QName qname = QName.create(qNameToRefNameEntry.getKey());
                 String namespace = qname.getNamespace().toString();
                 Map<String, Map<String, String>> serviceToRefs = retVal.get(namespace);
                 if(serviceToRefs==null) {
index 59a1d4fe7141bbe54a2dc770a4d2c789819bf52d..bdb4c1b067ff19947a01484165ba25563ba53e0a 100644 (file)
@@ -133,9 +133,9 @@ public final class Services {
         Element root = XmlUtil.createElement(document, XmlNetconfConstants.SERVICES_KEY, Optional.of(XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG));
 
         Map<String, Map<String, Map<String, String>>> mappedServices = serviceRegistryWrapper.getMappedServices();
-        for (String namespace : mappedServices.keySet()) {
+        for (Entry<String, Map<String, Map<String, String>>> namespaceToRefEntry : mappedServices.entrySet()) {
 
-            for (Entry<String, Map<String, String>> serviceEntry : mappedServices.get(namespace).entrySet()) {
+            for (Entry<String, Map<String, String>> serviceEntry : namespaceToRefEntry.getValue().entrySet()) {
                 // service belongs to config.yang namespace
                 Element serviceElement = XmlUtil.createElement(document, SERVICE_KEY, Optional.<String>absent());
                 root.appendChild(serviceElement);
@@ -143,7 +143,7 @@ public final class Services {
                 // type belongs to config.yang namespace
                 String serviceType = serviceEntry.getKey();
                 Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlNetconfConstants.TYPE_KEY,
-                        XmlNetconfConstants.PREFIX, namespace, serviceType);
+                        XmlNetconfConstants.PREFIX, namespaceToRefEntry.getKey(), serviceType);
 
                 serviceElement.appendChild(typeElement);
 
index 543a2c4a630d90de73dbf7aa0f837bf7dd2328f7..c22dcfe67bfb00233758b3b05cdc557ae5935a32 100644 (file)
@@ -148,21 +148,20 @@ public class EditConfig extends AbstractConfigNetconfOperation {
         Map<String, Map<String, Map<String, Services.ServiceInstance>>> namespaceToServiceNameToRefNameToInstance = services
                 .getNamespaceToServiceNameToRefNameToInstance();
 
-        for (String serviceNamespace : namespaceToServiceNameToRefNameToInstance.keySet()) {
-            for (String serviceName : namespaceToServiceNameToRefNameToInstance.get(serviceNamespace).keySet()) {
+        for (Map.Entry<String, Map<String, Map<String, Services.ServiceInstance>>> namespaceToServiceToRefEntry : namespaceToServiceNameToRefNameToInstance.entrySet()) {
+            for (Map.Entry<String, Map<String, Services.ServiceInstance>> serviceToRefEntry : namespaceToServiceToRefEntry.getValue().entrySet()) {
 
-                String qnameOfService = getQname(ta, serviceNamespace, serviceName);
-                Map<String, Services.ServiceInstance> refNameToInstance = namespaceToServiceNameToRefNameToInstance
-                        .get(serviceNamespace).get(serviceName);
+                String qnameOfService = getQname(ta, namespaceToServiceToRefEntry.getKey(), serviceToRefEntry.getKey());
+                Map<String, Services.ServiceInstance> refNameToInstance = serviceToRefEntry.getValue();
 
-                for (String refName : refNameToInstance.keySet()) {
-                    ObjectName on = refNameToInstance.get(refName).getObjectName(ta.getTransactionName());
+                for (Map.Entry<String, Services.ServiceInstance> refNameToServiceEntry : refNameToInstance.entrySet()) {
+                    ObjectName on = refNameToServiceEntry.getValue().getObjectName(ta.getTransactionName());
                     try {
-                        ObjectName saved = ta.saveServiceReference(qnameOfService, refName, on);
+                        ObjectName saved = ta.saveServiceReference(qnameOfService, refNameToServiceEntry.getKey(), on);
                         logger.debug("Saving service {} with on {} under name {} with service on {}", qnameOfService,
-                                on, refName, saved);
+                                on, refNameToServiceEntry.getKey(), saved);
                     } catch (InstanceNotFoundException e) {
-                        throw new NetconfDocumentedException(String.format("Unable to save ref name " + refName + " for instance " + on, e),
+                        throw new NetconfDocumentedException(String.format("Unable to save ref name " + refNameToServiceEntry.getKey() + " for instance " + on, e),
                                 ErrorType.application,
                                 ErrorTag.operation_failed,
                                 ErrorSeverity.error);
@@ -271,18 +270,18 @@ public class EditConfig extends AbstractConfigNetconfOperation {
 
         Map<String, Map<String, ModuleConfig>> namespaceToModuleNameToModuleConfig = Maps.newHashMap();
 
-        for (String namespace : mBeanEntries.keySet()) {
-            for (Map.Entry<String, ModuleMXBeanEntry> moduleNameToMbe : mBeanEntries.get(namespace).entrySet()) {
+        for (Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleToMbe : mBeanEntries.entrySet()) {
+            for (Map.Entry<String, ModuleMXBeanEntry> moduleNameToMbe : namespaceToModuleToMbe.getValue().entrySet()) {
                 String moduleName = moduleNameToMbe.getKey();
                 ModuleMXBeanEntry moduleMXBeanEntry = moduleNameToMbe.getValue();
 
                 ModuleConfig moduleConfig = new ModuleConfig(moduleName,
                         new InstanceConfig(configRegistryClient,moduleMXBeanEntry.getAttributes(), moduleMXBeanEntry.getNullableDummyContainerName()));
 
-                Map<String, ModuleConfig> moduleNameToModuleConfig = namespaceToModuleNameToModuleConfig.get(namespace);
+                Map<String, ModuleConfig> moduleNameToModuleConfig = namespaceToModuleNameToModuleConfig.get(namespaceToModuleToMbe.getKey());
                 if(moduleNameToModuleConfig == null) {
                     moduleNameToModuleConfig = Maps.newHashMap();
-                    namespaceToModuleNameToModuleConfig.put(namespace, moduleNameToModuleConfig);
+                    namespaceToModuleNameToModuleConfig.put(namespaceToModuleToMbe.getKey(), moduleNameToModuleConfig);
                 }
 
                 moduleNameToModuleConfig.put(moduleName, moduleConfig);
index fc95046dfdbef94e3e139480cae950c7010a83f9..9155bb95d2e73e812c46c15b3ff973cabb92875f 100644 (file)
@@ -54,13 +54,13 @@ public class Get extends AbstractConfigNetconfOperation {
             Map<String, Map<String, ModuleMXBeanEntry>> mBeanEntries) {
         Map<String, Map<String, ModuleRuntime>> retVal = Maps.newHashMap();
 
-        for (String namespace : mBeanEntries.keySet()) {
+        for (Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleEntry : mBeanEntries.entrySet()) {
 
             Map<String, ModuleRuntime> innerMap = Maps.newHashMap();
-            Map<String, ModuleMXBeanEntry> entriesFromNamespace = mBeanEntries.get(namespace);
-            for (String module : entriesFromNamespace.keySet()) {
+            Map<String, ModuleMXBeanEntry> entriesFromNamespace = namespaceToModuleEntry.getValue();
+            for (Map.Entry<String, ModuleMXBeanEntry> moduleToMXEntry : entriesFromNamespace.entrySet()) {
 
-                ModuleMXBeanEntry mbe = entriesFromNamespace.get(module);
+                ModuleMXBeanEntry mbe = moduleToMXEntry.getValue();
 
                 Map<RuntimeBeanEntry, InstanceConfig> cache = Maps.newHashMap();
                 RuntimeBeanEntry root = null;
@@ -77,10 +77,10 @@ public class Get extends AbstractConfigNetconfOperation {
 
                 InstanceRuntime rootInstanceRuntime = createInstanceRuntime(root, cache);
                 ModuleRuntime moduleRuntime = new ModuleRuntime(rootInstanceRuntime);
-                innerMap.put(module, moduleRuntime);
+                innerMap.put(moduleToMXEntry.getKey(), moduleRuntime);
             }
 
-            retVal.put(namespace, innerMap);
+            retVal.put(namespaceToModuleEntry.getKey(), innerMap);
         }
         return retVal;
     }
index 21021fec55661f69cd2c1e19325f0dd651e07193..0d9c61bad7b17b961294ce3562a7abca56f4d851 100644 (file)
@@ -81,8 +81,7 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation {
         final String[] signature = new String[attributes.size()];
 
         int i = 0;
-        for (final String attrName : attributes.keySet()) {
-            final AttributeConfigElement attribute = attributes.get(attrName);
+        for (final AttributeConfigElement attribute : attributes.values()) {
             final Optional<?> resolvedValueOpt = attribute.getResolvedValue();
 
             params[i] = resolvedValueOpt.isPresent() ? resolvedValueOpt.get() : attribute.getResolvedDefaultValue();
@@ -248,23 +247,23 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation {
 
         final Map<String, Map<String, ModuleRpcs>> map = Maps.newHashMap();
 
-        for (final String namespace : mBeanEntries.keySet()) {
+        for (final Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleEntry : mBeanEntries.entrySet()) {
 
-            Map<String, ModuleRpcs> namespaceToModules = map.get(namespace);
+            Map<String, ModuleRpcs> namespaceToModules = map.get(namespaceToModuleEntry.getKey());
             if (namespaceToModules == null) {
                 namespaceToModules = Maps.newHashMap();
-                map.put(namespace, namespaceToModules);
+                map.put(namespaceToModuleEntry.getKey(), namespaceToModules);
             }
 
-            for (final String moduleName : mBeanEntries.get(namespace).keySet()) {
+            for (final Map.Entry<String, ModuleMXBeanEntry> moduleEntry : namespaceToModuleEntry.getValue().entrySet()) {
 
-                ModuleRpcs rpcMapping = namespaceToModules.get(moduleName);
+                ModuleRpcs rpcMapping = namespaceToModules.get(moduleEntry.getKey());
                 if (rpcMapping == null) {
                     rpcMapping = new ModuleRpcs();
-                    namespaceToModules.put(moduleName, rpcMapping);
+                    namespaceToModules.put(moduleEntry.getKey(), rpcMapping);
                 }
 
-                final ModuleMXBeanEntry entry = mBeanEntries.get(namespace).get(moduleName);
+                final ModuleMXBeanEntry entry = moduleEntry.getValue();
 
                 for (final RuntimeBeanEntry runtimeEntry : entry.getRuntimeBeans()) {
                     rpcMapping.addNameMapping(runtimeEntry);
index beab62e997457055ce56ddbf646d40292905bf6a..11d2e748bfff0f2c3f4060e957a61b06d5e7e624 100644 (file)
@@ -55,7 +55,7 @@ public class TransactionProvider implements AutoCloseable {
         allOpenedTransactions.clear();
     }
 
-    public Optional<ObjectName> getTransaction() {
+    public synchronized Optional<ObjectName> getTransaction() {
 
         if (transaction == null){
             return Optional.absent();
index 5f311b5232ed676263925ce6af94b779c662df2e..b346522f4498b587c5550f7898f6a9639b48f395 100644 (file)
@@ -10,6 +10,9 @@ package org.opendaylight.controller.netconf.persist.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import com.google.common.base.Function;
+import com.google.common.base.Stopwatch;
+import com.google.common.collect.Collections2;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Collection;
@@ -23,10 +26,9 @@ import java.util.TreeMap;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-
+import javax.annotation.Nonnull;
 import javax.annotation.concurrent.Immutable;
 import javax.management.MBeanServerConnection;
-
 import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.persist.api.ConfigPusher;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
@@ -49,10 +51,6 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
-import com.google.common.base.Function;
-import com.google.common.base.Stopwatch;
-import com.google.common.collect.Collections2;
-
 @Immutable
 public class ConfigPusherImpl implements ConfigPusher {
     private static final Logger logger = LoggerFactory.getLogger(ConfigPusherImpl.class);
@@ -200,7 +198,7 @@ public class ConfigPusherImpl implements ConfigPusher {
     private static Set<String> computeNotFoundCapabilities(Set<String> expectedCapabilities, NetconfOperationService serviceCandidate) {
         Collection<String> actual = Collections2.transform(serviceCandidate.getCapabilities(), new Function<Capability, String>() {
             @Override
-            public String apply(Capability input) {
+            public String apply(@Nonnull final Capability input) {
                 return input.getCapabilityUri();
             }
         });
index 81fac5f12f9c7dc9d3bf40922c19723836c036ce..2a45e1757b8655a6b6be8bcf097867b677fd70d1 100644 (file)
@@ -13,6 +13,10 @@ import com.google.common.collect.Collections2;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import io.netty.util.internal.ConcurrentSet;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
 import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
 import org.opendaylight.controller.netconf.mapping.api.Capability;
@@ -32,11 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.mon
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nullable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
 public class NetconfMonitoringServiceImpl implements NetconfMonitoringService, SessionMonitoringService {
 
     private static final Logger logger = LoggerFactory.getLogger(NetconfMonitoringServiceImpl.class);
@@ -134,9 +133,8 @@ public class NetconfMonitoringServiceImpl implements NetconfMonitoringService, S
 
     private List<Session> transformSessions(Set<NetconfManagementSession> sessions) {
         return Lists.newArrayList(Collections2.transform(sessions, new Function<NetconfManagementSession, Session>() {
-            @Nullable
             @Override
-            public Session apply(@Nullable NetconfManagementSession input) {
+            public Session apply(@Nonnull NetconfManagementSession input) {
                 return input.toManagementSession();
             }
         }));
index ff96ad779fbc974539ced455494129381bb09635..aa590604b0087d5f7cc79f135a246b6a929abe07 100644 (file)
@@ -48,7 +48,7 @@ public class NetconfOperationRouterImpl implements NetconfOperationRouter {
         this.netconfOperationServiceSnapshot = netconfOperationServiceSnapshot;
     }
 
-    private void initNetconfOperations(Set<NetconfOperation> allOperations) {
+    private synchronized void initNetconfOperations(Set<NetconfOperation> allOperations) {
         allNetconfOperations = allOperations;
     }
 
index 078509db40f1c71d511bf5881e75b79e75e0f82c..16b38eca5172a96a6254713dbefb6dbd44324949 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.netconf.monitoring.xml.model;
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Collections2;
+import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
 
@@ -41,7 +42,7 @@ final class MonitoringSchema {
         return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
             @Nullable
             @Override
-            public String apply(@Nullable Schema.Location input) {
+            public String apply(@Nonnull Schema.Location input) {
                 return input.getEnumeration().toString();
             }
         });
index c686bcbc66fcb849da3f357bdd3bea2df7f62f2e..0d0f95c3cb4d0856ba56c470f0890eb51371caa1 100644 (file)
@@ -123,6 +123,7 @@ public class NetconfSSHActivator implements BundleActivator {
             final AuthProvider authService = bundleContext.getService(reference);
             final Integer newServicePreference = getPreference(reference);
             if(isBetter(newServicePreference)) {
+                maxPreference = newServicePreference;
                 server.setAuthProvider(authService);
                 if(sshThread == null) {
                     sshThread = runNetconfSshThread(server);
index d314c31b4fcd6288821109046e59cf1b20fd7ef8..da5e2090ff4cfb70d0c253ad339154dccd9ac107 100644 (file)
@@ -71,7 +71,7 @@ public class AuthProviderImpl implements AuthProvider {
     }
 
     @VisibleForTesting
-    void setNullableUserManager(final IUserManager nullableUserManager) {
+    synchronized void setNullableUserManager(final IUserManager nullableUserManager) {
         this.nullableUserManager = nullableUserManager;
     }
 }
index 25e0f7926574c3168bc013cff865ec2f6a8a33db..b6f5854aa331140cf21c1de433c5f4a9263e6201 100644 (file)
@@ -116,8 +116,8 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
             rpcReply.appendChild(responseNS);
         }
 
-        for (String attrName : attributes.keySet()) {
-            rpcReply.setAttributeNode((Attr) document.importNode(attributes.get(attrName), true));
+        for (Attr attribute : attributes.values()) {
+            rpcReply.setAttributeNode((Attr) document.importNode(attribute, true));
         }
         document.appendChild(rpcReply);
         return document;
index 3e8040ad8a1d87e916415795e08e38814963537b..c532b7f9a6f235a0eebc7dc4a53bc10f2208dbc4 100644 (file)
@@ -10,7 +10,9 @@ package org.opendaylight.controller.netconf.util.messages;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
-
+import java.util.Collection;
+import java.util.List;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
@@ -19,11 +21,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 
-import javax.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.List;
-
 public final class NetconfMessageUtil {
 
     private static final Logger logger = LoggerFactory.getLogger(NetconfMessageUtil.class);
@@ -67,9 +64,8 @@ public final class NetconfMessageUtil {
         List<XmlElement> caps = capabilitiesElement.getChildElements(XmlNetconfConstants.CAPABILITY);
         return Collections2.transform(caps, new Function<XmlElement, String>() {
 
-            @Nullable
             @Override
-            public String apply(@Nullable XmlElement input) {
+            public String apply(@Nonnull XmlElement input) {
                 // Trim possible leading/tailing whitespace
                 try {
                     return input.getTextContent().trim();
index 4e3a66b7ec5f7edfe0399bcab74e6a1843ed0449..78efe7e9723154bd218bafa5d248af0329fb567d 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import javax.annotation.Nullable;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException;
 import org.opendaylight.controller.netconf.util.exception.UnexpectedElementException;
@@ -204,7 +203,7 @@ public final class XmlElement {
         return Lists.newArrayList(Collections2.filter(getChildElementsWithinNamespace(namespace),
                 new Predicate<XmlElement>() {
                     @Override
-                    public boolean apply(@Nullable XmlElement xmlElement) {
+                    public boolean apply(XmlElement xmlElement) {
                         return xmlElement.getName().equals(childName);
                     }
                 }));
@@ -298,7 +297,7 @@ public final class XmlElement {
         List<XmlElement> children = getChildElementsWithinNamespace(namespace);
         children = Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
             @Override
-            public boolean apply(@Nullable XmlElement xmlElement) {
+            public boolean apply(XmlElement xmlElement) {
                 return xmlElement.getName().equals(childName);
             }
         }));
@@ -436,7 +435,7 @@ public final class XmlElement {
         List<XmlElement> children = getChildElementsWithinNamespace(getNamespace());
         return Lists.newArrayList(Collections2.filter(children, new Predicate<XmlElement>() {
             @Override
-            public boolean apply(@Nullable XmlElement xmlElement) {
+            public boolean apply(XmlElement xmlElement) {
                 return xmlElement.getName().equals(childName);
             }
         }));