BUG-1425: fix toString() invocation on LazyObject 56/9856/1
authorRobert Varga <rovarga@cisco.com>
Mon, 11 Aug 2014 14:02:28 +0000 (16:02 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 11 Aug 2014 14:02:28 +0000 (16:02 +0200)
When we are coming in from toString(), the proxy invocation does not
work. Extract getAugmentations() into a private method and use that
instead.

Change-Id: Ia851560b7703817f6d75887fa7e80037292e3fd1
Signed-off-by: Robert Varga <rovarga@cisco.com>
code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/LazyDataObject.java

index 66b47cc76e14934d38f0e8bf5c412abf391f05fe..d7ede0fbb83ad1dc719ab4e211b0095ca8c70959 100644 (file)
@@ -136,11 +136,7 @@ class LazyDataObject implements InvocationHandler, AugmentationReader {
         return cached == NULL_VALUE ? null : cached;
     }
 
-    @Override
-    public Map<Class<? extends Augmentation<?>>, Augmentation<?>> getAugmentations(final Object obj) {
-        Preconditions.checkArgument(this == Proxy.getInvocationHandler(obj),
-                "Supplied object is not associated with this proxy handler");
-
+    private Map<Class<? extends Augmentation<?>>, Augmentation<?>> getAugmentationsImpl() {
         ImmutableMap<Class<? extends Augmentation<?>>, Augmentation<?>> ret = cachedAugmentations;
         if (ret == null) {
             synchronized (this) {
@@ -155,6 +151,14 @@ class LazyDataObject implements InvocationHandler, AugmentationReader {
         return ret;
     }
 
+    @Override
+    public Map<Class<? extends Augmentation<?>>, Augmentation<?>> getAugmentations(final Object obj) {
+        Preconditions.checkArgument(this == Proxy.getInvocationHandler(obj),
+                "Supplied object is not associated with this proxy handler");
+
+        return getAugmentationsImpl();
+    }
+
     private Object getAugmentationImpl(final Class<?> cls) {
         final ImmutableMap<Class<? extends Augmentation<?>>, Augmentation<?>> aug = cachedAugmentations;
         if (aug != null) {
@@ -176,7 +180,7 @@ class LazyDataObject implements InvocationHandler, AugmentationReader {
             helper.add(m.getName(), getBindingData(m));
         }
         if (Augmentable.class.isAssignableFrom(context.bindingClass())) {
-            helper.add("augmentations", getAugmentations(this));
+            helper.add("augmentations", getAugmentationsImpl());
         }
         return helper.toString();
     }