BUG-1027: emit more diagnostics when augmentation is not found 59/7159/1
authorRobert Varga <rovarga@cisco.com>
Sun, 18 May 2014 13:58:37 +0000 (15:58 +0200)
committerRobert Varga <rovarga@cisco.com>
Sun, 18 May 2014 14:29:03 +0000 (16:29 +0200)
This adds more stern warnings when we fail to find augmentation targets.

Change-Id: Iec338917e7f175c4e977529761f1e8fa272d0bb1
Signed-off-by: Robert Varga <rovarga@cisco.com>
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java

index 12b960c1a3b4d5b9c24f29d091576d19296a03d6..a2c1e4ce88f590e87cafe2bfc74448672bfc0a73 100644 (file)
@@ -166,12 +166,21 @@ class LazyGeneratedCodecRegistry implements //
             codec = new AugmentationCodecWrapper<T>(rawCodec, null, object);
             augmentationCodecs.put(object, codec);
         }
-        Class<? extends Augmentable<?>> objectSupertype = getAugmentableArgumentFrom(object);
-        if (objectSupertype != null) {
-            getAugmentableCodec(objectSupertype).addImplementation(codec);
-        } else {
-            LOG.warn("Could not find augmentation target for augmentation {}", object);
+
+        final Class<? extends Augmentable<?>> objectSupertype;
+        try {
+            objectSupertype = BindingReflections.findAugmentationTarget(object);
+        } catch (Exception e) {
+            LOG.warn("Failed to find target for augmentation {}, ignoring it", object, e);
+            return codec;
         }
+
+        if (objectSupertype == null) {
+            LOG.warn("Augmentation target for {} not found, ignoring it", object);
+            return codec;
+        }
+
+        getAugmentableCodec(objectSupertype).addImplementation(codec);
         return codec;
     }
 
@@ -182,18 +191,6 @@ class LazyGeneratedCodecRegistry implements //
         return getCodecForAugmentation((Class<? extends Augmentation<?>>) cls).getAugmentationQName();
     }
 
-    private static Class<? extends Augmentable<?>> getAugmentableArgumentFrom(
-            final Class<? extends Augmentation<?>> augmentation) {
-        try {
-            Class<? extends Augmentable<?>> ret = BindingReflections.findAugmentationTarget(augmentation);
-            return ret;
-
-        } catch (Exception e) {
-            LOG.debug("Could not find augmentable for {} using {}", augmentation, augmentation.getClassLoader(), e);
-            return null;
-        }
-    }
-
     @Override
     public Class<?> getClassForPath(final List<QName> names) {
         final DataSchemaNode node = getSchemaNode(names);