inc. BindingRuntimeContext details in "Schema .. is not available" 20/73320/6
authorMichael Vorburger <vorburger@redhat.com>
Thu, 21 Jun 2018 15:56:40 +0000 (17:56 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Tue, 31 Jul 2018 09:07:04 +0000 (11:07 +0200)
but in a debug log, not the IllegalStateException, because it's huge.

JIRA: MDSAL-354
Change-Id: I65c236fc3b675e7cf231cc1d8cdc56fc36131281
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingToNormalizedNodeCodec.java
binding/mdsal-binding-generator-api/src/main/java/org/opendaylight/mdsal/binding/generator/api/BindingRuntimeTypes.java
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/util/BindingRuntimeContext.java

index 561b4467034a4e8b454dfe7eae75fc364c2610bc..1e6c4f7d10bd4a3a516ad5d52e4a609f5397d443 100644 (file)
@@ -368,9 +368,14 @@ public class BindingToNormalizedNodeCodec implements BindingCodecTreeFactory,
             checkState(localRuntimeContext != null, "BindingRuntimeContext is not available.");
             module = localRuntimeContext.getSchemaContext().findModule(moduleName).orElse(null);
         }
-        checkState(module != null, "Schema for %s is not available; expected module name: %s.", modeledClass,
-                moduleName);
-        return module;
+        if (module != null) {
+            return module;
+        }
+
+        LOG.debug("Schema for {} is not available; expected module name: {}; BindingRuntimeContext: {}",
+                modeledClass, moduleName, localRuntimeContext);
+        throw new IllegalStateException(String.format("Schema for %s is not available; expected module name: %s; "
+                + "full BindingRuntimeContext available in debug log", modeledClass, moduleName));
     }
 
     private void waitForSchema(final Collection<Class<?>> binding, final MissingSchemaException exception) {
index 007992b4ca0f8787f8b047c0815b9fe9e1a35039..94594c2f7bf8a9f77a800a8cda9eb13dd89feeea 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.mdsal.binding.generator.api;
 
 import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.ImmutableBiMap;
 import com.google.common.collect.ImmutableMap;
@@ -29,6 +30,7 @@ import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
 @Beta
 @ThreadSafe
 public final class BindingRuntimeTypes implements Immutable {
+
     private final Map<Type, AugmentationSchemaNode> typeToAugmentation;
     private final BiMap<Type, WithStatus> typeToSchema;
     private final Multimap<Type, Type> choiceToCases;
@@ -66,4 +68,14 @@ public final class BindingRuntimeTypes implements Immutable {
     public Collection<Type> findCases(final Type choiceType) {
         return choiceToCases.get(choiceType);
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("typeToAugmentation", typeToAugmentation)
+                .add("typeToSchema", typeToSchema)
+                .add("choiceToCases", choiceToCases)
+                .add("identities", identities)
+                .toString();
+    }
 }
index 5c4d60fead55ad76deca357b0b2953e0a6bb6c10..4fb2f39bd1fc7536c93ef87b2f64d3d47bbbc805 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.mdsal.binding.generator.util;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 
+import com.google.common.base.MoreObjects;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.cache.CacheBuilder;
@@ -485,4 +486,12 @@ public final class BindingRuntimeContext implements Immutable {
     public Class<?> getIdentityClass(final QName input) {
         return identityClasses.getUnchecked(input);
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("ClassLoadingStrategy", strategy)
+                .add("runtimeTypes", runtimeTypes)
+                .add("schemaContext", schemaContext).toString();
+    }
 }