From: Robert Varga Date: Sun, 18 May 2014 13:58:37 +0000 (+0200) Subject: BUG-1027: emit more diagnostics when augmentation is not found X-Git-Tag: release/helium~547 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=2952d48e853a70d20a59fe427a37280f9131d452;p=yangtools.git BUG-1027: emit more diagnostics when augmentation is not found This adds more stern warnings when we fail to find augmentation targets. Change-Id: Iec338917e7f175c4e977529761f1e8fa272d0bb1 Signed-off-by: Robert Varga --- diff --git a/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java b/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java index 12b960c1a3..a2c1e4ce88 100644 --- a/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java +++ b/code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java @@ -166,12 +166,21 @@ class LazyGeneratedCodecRegistry implements // codec = new AugmentationCodecWrapper(rawCodec, null, object); augmentationCodecs.put(object, codec); } - Class> objectSupertype = getAugmentableArgumentFrom(object); - if (objectSupertype != null) { - getAugmentableCodec(objectSupertype).addImplementation(codec); - } else { - LOG.warn("Could not find augmentation target for augmentation {}", object); + + final Class> 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>) cls).getAugmentationQName(); } - private static Class> getAugmentableArgumentFrom( - final Class> augmentation) { - try { - Class> 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 names) { final DataSchemaNode node = getSchemaNode(names);