Fixed possible NPE, improved logging. 66/5466/1
authorMartin Vitez <mvitez@cisco.com>
Wed, 26 Feb 2014 08:19:28 +0000 (09:19 +0100)
committerMartin Vitez <mvitez@cisco.com>
Wed, 26 Feb 2014 08:26:27 +0000 (09:26 +0100)
Signed-off-by: Martin Vitez <mvitez@cisco.com>
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java

index 1fb88990bf5e60fc3f4e8fce067d554418900b9b..1fabec11b86c99ef834306807b9676d70eb926d2 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.yangtools.binding.generator.util.Types;
 import org.opendaylight.yangtools.concepts.Delegator;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.sal.binding.generator.util.ClassLoaderUtils;
+import org.opendaylight.yangtools.sal.binding.generator.util.CodeGenerationException;
 import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
@@ -540,7 +541,7 @@ public class LazyGeneratedCodecRegistry implements //
                 for (AugmentationSchema augment : augments) {
                     Type augmentType = augmentToType.get(augment);
                     if (augmentType == null) {
-                        LOG.warn("Failed to find type for augmentation of " + augment);
+                        LOG.warn("Failed to find type for augmentation of {}", augment);
                     } else {
                         augmentTypes.add(augmentType);
                     }
@@ -549,10 +550,12 @@ public class LazyGeneratedCodecRegistry implements //
                     Class<? extends Augmentation<?>> clazz = null;
                     try {
                         clazz = (Class<? extends Augmentation<?>>) classLoadingStrategy.loadClass(augmentType);
+                        getCodecForAugmentation(clazz);
                     } catch (ClassNotFoundException e) {
-                        LOG.warn("Failed to find class for augmentation of " + augmentType);
+                        LOG.warn("Failed to find class for augmentation of {}, reason: {}", augmentType, e.toString());
+                    } catch (CodeGenerationException e) {
+                        LOG.warn("Failed to proactively generate augment coded for {}, reason: {}",  augmentType, e.toString());
                     }
-                    getCodecForAugmentation(clazz);
                 }
             }
         }