Fixed major sonar warnings in Binding Aware Broker 93/3293/1
authorTony Tkacik <ttkacik@cisco.com>
Sun, 1 Dec 2013 13:30:02 +0000 (14:30 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Sun, 1 Dec 2013 13:30:02 +0000 (14:30 +0100)
Change-Id: I3c5721372778bc963d4fb1d5ff38585a7aa133af
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
14 files changed:
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModuleFactory.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/DataBrokerImplModuleFactory.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/NotificationBrokerImplModuleFactory.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RpcBrokerImplModuleFactory.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModule.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/RuntimeMappingModuleFactory.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/CodecMapping.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentDataServiceConnector.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/util/ClassLoaderUtils.java

index c3fe5f7..bce1f61 100644 (file)
@@ -15,8 +15,7 @@ import org.osgi.framework.BundleContext;
 /**
 *
 */
-public final class BindingBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule
-{
+public final class BindingBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {
 
     private BundleContext bundleContext;
 
index 5390251..1c03c3e 100644 (file)
@@ -17,8 +17,7 @@ import org.osgi.framework.BundleContext;
 /**
 *
 */
-public class BindingBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModuleFactory
-{
+public class BindingBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModuleFactory {
 
     
     @Override
index 4022dd4..60c8156 100644 (file)
@@ -1,12 +1,12 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-data-broker
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 17:33:01 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-data-broker
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:33:01 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 import org.opendaylight.controller.config.api.DependencyResolver;
@@ -17,20 +17,22 @@ import org.osgi.framework.BundleContext;
 /**
 *
 */
-public class DataBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractDataBrokerImplModuleFactory
-{
+public class DataBrokerImplModuleFactory extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractDataBrokerImplModuleFactory {
 
     @Override
     public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
-        DataBrokerImplModule module = (DataBrokerImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+        DataBrokerImplModule module = (DataBrokerImplModule) super.createModule(instanceName, dependencyResolver,
+                bundleContext);
         module.setBundleContext(bundleContext);
         return module;
     }
-    
+
     @Override
     public Module createModule(String instanceName, DependencyResolver dependencyResolver,
             DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
-        DataBrokerImplModule module = (DataBrokerImplModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        DataBrokerImplModule module = (DataBrokerImplModule) super.createModule(instanceName, dependencyResolver, old,
+                bundleContext);
         module.setBundleContext(bundleContext);
         return module;
     }
index 72231d1..e4f74de 100644 (file)
@@ -1,12 +1,12 @@
 /**
-* Generated file
-
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-notification-broker
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 17:33:01 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated file
+
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-notification-broker
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:33:01 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 import java.util.concurrent.ExecutorService;
@@ -21,19 +21,22 @@ import com.google.common.util.concurrent.MoreExecutors;
 /**
 *
 */
-public final class NotificationBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractNotificationBrokerImplModule
-{
+public final class NotificationBrokerImplModule extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractNotificationBrokerImplModule {
 
-    public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NotificationBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public NotificationBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            NotificationBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
     @Override
-    public void validate(){
+    public void validate() {
         super.validate();
         // Add custom validation for module attributes here.
     }
index 24ca0bb..31613a7 100644 (file)
@@ -1,19 +1,18 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-notification-broker
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 17:33:01 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-notification-broker
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:33:01 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 /**
 *
 */
-public class NotificationBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractNotificationBrokerImplModuleFactory
-{
-
+public class NotificationBrokerImplModuleFactory extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractNotificationBrokerImplModuleFactory {
 
 }
index 7824da8..b0d3f7a 100644 (file)
@@ -1,37 +1,40 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-rpc-broker
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 17:33:01 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-rpc-broker
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:33:01 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 /**
 *
 */
-public final class RpcBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRpcBrokerImplModule
-{
+public final class RpcBrokerImplModule extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRpcBrokerImplModule {
 
-    public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, RpcBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public RpcBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            RpcBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
     @Override
-    public void validate(){
+    public void validate() {
         super.validate();
         // Add custom validation for module attributes here.
     }
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        //TODO:implement
+        // TODO:implement
         throw new java.lang.UnsupportedOperationException("Unimplemented stub method");
     }
 }
index 61c7364..ed3371a 100644 (file)
@@ -1,19 +1,18 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-rpc-broker
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 17:33:01 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-rpc-broker
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 17:33:01 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 /**
 *
 */
-public class RpcBrokerImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRpcBrokerImplModuleFactory
-{
-
+public class RpcBrokerImplModuleFactory extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRpcBrokerImplModuleFactory {
 
 }
index 6537b4c..1bf15c1 100644 (file)
@@ -1,12 +1,12 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 18:20:19 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 18:20:19 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 import javassist.ClassPool;
@@ -19,26 +19,29 @@ import com.google.common.base.Preconditions;
 /**
 *
 */
-public final class RuntimeMappingModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModule
-{
+public final class RuntimeMappingModule extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModule {
 
     private BundleContext bundleContext;
 
-    public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, RuntimeMappingModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public RuntimeMappingModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            RuntimeMappingModule oldModule, java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
     @Override
-    public void validate(){
+    public void validate() {
         super.validate();
         Preconditions.checkNotNull(bundleContext);
         // Add custom validation for module attributes here.
     }
-    
+
     @Override
     public boolean canReuseInstance(AbstractRuntimeMappingModule oldModule) {
         return true;
index f104c73..6344ae9 100644 (file)
@@ -1,12 +1,12 @@
 /**
-* Generated file
+ * Generated file
 
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Wed Nov 20 18:20:19 CET 2013
-*
-* Do not modify this file unless it is present under src/main directory
-*/
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: runtime-generated-mapping
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Nov 20 18:20:19 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
 
 import java.util.Collections;
@@ -22,36 +22,35 @@ import org.osgi.framework.BundleContext;
 /**
 *
 */
-public class RuntimeMappingModuleFactory extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModuleFactory
-{
+public class RuntimeMappingModuleFactory extends
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractRuntimeMappingModuleFactory {
 
-    
-    private static  RuntimeMappingModule SINGLETON = null;
+    private static RuntimeMappingModule SINGLETON = null;
     private static ModuleIdentifier IDENTIFIER = new ModuleIdentifier(NAME, "runtime-mapping-singleton");
 
     @Override
     public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
         throw new UnsupportedOperationException("Only default instance supported");
     }
-    
+
     @Override
     public Module createModule(String instanceName, DependencyResolver dependencyResolver,
             DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
-        RuntimeMappingModule module = (RuntimeMappingModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        RuntimeMappingModule module = (RuntimeMappingModule) super.createModule(instanceName, dependencyResolver, old,
+                bundleContext);
         module.setBundleContext(bundleContext);
         return module;
     }
-    
+
     @Override
     public Set<RuntimeMappingModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
             BundleContext bundleContext) {
-        if(SINGLETON == null) {
+        if (SINGLETON == null) {
             DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(IDENTIFIER);
-            SINGLETON = new RuntimeMappingModule(IDENTIFIER , dependencyResolver);
+            SINGLETON = new RuntimeMappingModule(IDENTIFIER, dependencyResolver);
             SINGLETON.setBundleContext(bundleContext);
         }
-        
-        
+
         return Collections.singleton(SINGLETON);
     }
 
index d05967c..79a11ce 100644 (file)
@@ -7,9 +7,13 @@ import org.opendaylight.controller.sal.binding.dom.serializer.api.InstanceIdenti
 import org.opendaylight.yangtools.yang.binding.BindingCodec;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CodecMapping {
 
+    private static final Logger LOG = LoggerFactory.getLogger(CodecMapping.class);
+    
     public static final String INSTANCE_IDENTIFIER_CODEC = "INSTANCE_IDENTIFIER_CODEC";
     public static final String CLASS_TO_CASE_MAP = "CLASS_TO_CASE";
     public static final String COMPOSITE_TO_CASE = "COMPOSITE_TO_CASE";
@@ -19,13 +23,13 @@ public class CodecMapping {
         Field instanceIdField;
         try {
             instanceIdField = obj.getField(INSTANCE_IDENTIFIER_CODEC);
-            instanceIdField.set(null, codec);
+            if(obj != null) {
+                instanceIdField.set(null, codec);
+            }
         } catch (NoSuchFieldException e) {
-           // NOOP
-        } catch (SecurityException e) {
-            // NOOP
-        } catch (IllegalAccessException e) {
-            // NOOp
+           LOG.debug("Instance identifier codec is not needed for {}",obj.getName(),e);
+        } catch (SecurityException | IllegalAccessException e) {
+            LOG.error("Instance identifier could not be set for {}",obj.getName(),e);
         }
     }
 
@@ -36,14 +40,10 @@ public class CodecMapping {
             instanceIdField = codec.getField(CLASS_TO_CASE_MAP);
             instanceIdField.set(null, classToCaseRawCodec);
         } catch (NoSuchFieldException e) {
-           // NOOP
-        } catch (SecurityException e) {
-            // NOOP
-        } catch (IllegalAccessException e) {
-            // NOOp
+            LOG.debug("BUG: Class to case mappping is not needed for {}",codec.getName(),e);
+        } catch (SecurityException | IllegalAccessException e) {
+            LOG.error("Class to case mappping could not be set for {}",codec.getName(),e);
         }
-        
-        
     }
 
     public static void setCompositeNodeToCaseMap(Class<? extends BindingCodec<?,?>> codec,
@@ -53,11 +53,9 @@ public class CodecMapping {
             instanceIdField = codec.getField(COMPOSITE_TO_CASE);
             instanceIdField.set(null, compositeToCase);
         } catch (NoSuchFieldException e) {
-           // NOOP
-        } catch (SecurityException e) {
-            // NOOP
-        } catch (IllegalAccessException e) {
-            // NOOp
+            LOG.debug("BUG: Class to case mappping is not needed for {}",codec.getName(),e);
+        } catch (SecurityException | IllegalAccessException e) {
+            LOG.error("Composite node to case mappping could not be set for {}",codec.getName(),e);
         }
     }
 
@@ -68,11 +66,9 @@ public class CodecMapping {
                 instanceIdField = dataCodec.getField(AUGMENTATION_CODEC);
                 instanceIdField.set(null, augmentableCodec);
             } catch (NoSuchFieldException e) {
-               // NOOP
-            } catch (SecurityException e) {
-                // NOOP
-            } catch (IllegalAccessException e) {
-                // NOOp
+                LOG.debug("BUG: Augmentation codec is not needed for {}",dataCodec.getName(),e);
+            } catch (SecurityException | IllegalAccessException e) {
+                LOG.error("Augmentation codec could not be set for {}",dataCodec.getName(),e);
             }
     }
 }
index a55d4b9..961cb2e 100644 (file)
@@ -478,7 +478,7 @@ public class LazyGeneratedCodecRegistry implements //
 
         @Override
         public boolean isAcceptable(Node<?> input) {
-            if (false == (input instanceof CompositeNode)) {
+            if (!(input instanceof CompositeNode)) {
                 if (augmenting) {
                     return checkAugmenting((CompositeNode) input);
                 } else {
@@ -492,10 +492,7 @@ public class LazyGeneratedCodecRegistry implements //
             QName parent = input.getNodeType();
             for (Node<?> childNode : input.getChildren()) {
                 QName child = childNode.getNodeType();
-                if (false == Objects.equals(parent.getNamespace(), child.getNamespace())) {
-                    continue;
-                }
-                if (false == Objects.equals(parent.getRevision(), child.getRevision())) {
+                if (!Objects.equals(parent.getNamespace(), child.getNamespace()) || Objects.equals(parent.getRevision(), child.getRevision())) {
                     continue;
                 }
                 if (validNames.contains(child.getLocalName())) {
@@ -558,7 +555,7 @@ public class LazyGeneratedCodecRegistry implements //
 
         @Override
         public Set<java.util.Map.Entry<Class, BindingCodec<Object, Object>>> entrySet() {
-            return null;
+            return Collections.emptySet();
         }
 
         @Override
@@ -584,7 +581,7 @@ public class LazyGeneratedCodecRegistry implements //
 
         @Override
         public BindingCodec get(Object key) {
-            if (false == (key instanceof CompositeNode)) {
+            if (!(key instanceof CompositeNode)) {
                 return null;
             }
             for (java.util.Map.Entry<Class, ChoiceCaseCodecImpl<?>> entry : choiceCases.entrySet()) {
@@ -636,7 +633,7 @@ public class LazyGeneratedCodecRegistry implements //
 
         @Override
         public Collection<BindingCodec<?, ?>> values() {
-            return null;
+            return Collections.emptySet();
         }
 
         private UnsupportedOperationException notModifiable() {
@@ -660,18 +657,17 @@ public class LazyGeneratedCodecRegistry implements //
 
         @Override
         public boolean isEmpty() {
-            return false;
+            return true;
         }
 
         @Override
         public Set<T> keySet() {
-            return null;
+            return Collections.emptySet();
         }
 
         @Override
         public Set<java.util.Map.Entry<T, BindingCodec<?, ?>>> entrySet() {
-            // TODO Auto-generated method stub
-            return null;
+            return Collections.emptySet();
         }
 
         @Override
@@ -709,15 +705,9 @@ public class LazyGeneratedCodecRegistry implements //
                 augmentationField.setAccessible(true);
                 Map<Class, Augmentation> augMap = (Map<Class, Augmentation>) augmentationField.get(input);
                 return augMap;
-            } catch (NoSuchFieldException e) {
-
-            } catch (SecurityException e) {
-
-            } catch (IllegalArgumentException e) {
-
-            } catch (IllegalAccessException e) {
-
-            }
+            } catch (IllegalArgumentException | IllegalAccessException |NoSuchFieldException | SecurityException e) {
+                LOG.debug("Could not read augmentations for {}",input,e);
+            } 
             return Collections.emptyMap();
         }
 
@@ -742,9 +732,9 @@ public class LazyGeneratedCodecRegistry implements //
                 rawAugmentationCodecs.put(key, ret);
                 return ret;
             } catch (InstantiationException e) {
-
+                LOG.error("Can not instantiate raw augmentation codec {}",key.getSimpleName(),e);
             } catch (IllegalAccessException e) {
-
+                LOG.debug("BUG: Constructor for {} is not accessible.",key.getSimpleName(),e);
             }
             return null;
         }
index ec69fd3..0da7aec 100644 (file)
@@ -149,6 +149,7 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         try {
             deserializationBlock.call()
         } catch (Exception e) {
+
             // FIXME: Make this block providing more information.
             throw new DeserializationException(e);
         }
index 6478a03..cb3206a 100644 (file)
@@ -1,7 +1,5 @@
 package org.opendaylight.controller.sal.binding.impl.util;
 
-
-
 import java.util.concurrent.Callable;
 import java.util.concurrent.locks.Lock;
 
@@ -10,50 +8,55 @@ import static com.google.common.base.Preconditions.*;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
+import java.util.List;
 
 import com.google.common.base.Optional;
 
-public class ClassLoaderUtils {
-    
-    public static <V> V withClassLoader(ClassLoader cls,Callable<V> function) throws Exception {
-        return withClassLoaderAndLock(cls, Optional.<Lock>absent(), function);
+public final class ClassLoaderUtils {
+
+    private ClassLoaderUtils() {
+        throw new UnsupportedOperationException("Utility class");
+    }
+
+    public static <V> V withClassLoader(ClassLoader cls, Callable<V> function) throws Exception {
+        return withClassLoaderAndLock(cls, Optional.<Lock> absent(), function);
     }
-    
-    public static <V> V withClassLoaderAndLock(ClassLoader cls,Lock lock,Callable<V> function) throws Exception {
-        checkNotNull(lock,"Lock should not be null");
+
+    public static <V> V withClassLoaderAndLock(ClassLoader cls, Lock lock, Callable<V> function) throws Exception {
+        checkNotNull(lock, "Lock should not be null");
         return withClassLoaderAndLock(cls, Optional.of(lock), function);
     }
-    
-    public static <V> V withClassLoaderAndLock(ClassLoader cls,Optional<Lock> lock,Callable<V> function) throws Exception {
+
+    public static <V> V withClassLoaderAndLock(ClassLoader cls, Optional<Lock> lock, Callable<V> function)
+            throws Exception {
         checkNotNull(cls, "Classloader should not be null");
-        checkNotNull(function,"Function should not be null");
-        if(lock.isPresent()) {
+        checkNotNull(function, "Function should not be null");
+        if (lock.isPresent()) {
             lock.get().lock();
         }
         ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(cls);
-            V result = function.call();
-            return result;
-        }  finally {
+            return function.call();
+        } finally {
             Thread.currentThread().setContextClassLoader(oldCls);
-            if(lock.isPresent()) {
+            if (lock.isPresent()) {
                 lock.get().unlock();
             }
         }
     }
 
-    public static Object construct(Constructor<? extends Object> constructor, ArrayList<Object> objects) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-    Object[] initargs = objects.toArray(new Object[]{});
-    return constructor.newInstance(initargs);
+    public static Object construct(Constructor<? extends Object> constructor, List<Object> objects)
+            throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        Object[] initargs = objects.toArray(new Object[] {});
+        return constructor.newInstance(initargs);
     }
-    
-    
+
     public static Class<?> loadClassWithTCCL(String name) throws ClassNotFoundException {
-        if("byte[]".equals(name)) {
+        if ("byte[]".equals(name)) {
             return byte[].class;
         }
-        
+
         return Thread.currentThread().getContextClassLoader().loadClass(name);
     }
 }
\ No newline at end of file