BUG-4456: add RecursiveExtensionResolver
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / BuildGlobalContext.java
index 8bc0936327441acc94cae0622ae5e33033d96e2c..62822474d7042f4659c9bde7afcaced862b000ef 100644 (file)
@@ -46,6 +46,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamesp
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.PhaseCompletionProgress;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.RecursiveObjectLeaker;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
 import org.slf4j.Logger;
@@ -71,7 +72,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
     private final boolean enabledSemanticVersions;
 
     public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
-            StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
+            final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
         super();
         this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
         Preconditions.checkNotNull(statementParserMode, "Statement parser mode must not be null.");
@@ -83,7 +84,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
 
     public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
             final Map<ValidationBundleType, Collection<?>> supportedValidation,
-            StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
+            final StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
         super();
         this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
         Preconditions.checkNotNull(statementParserMode, "Statement parser mode must not be null.");
@@ -216,6 +217,8 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
             }
         } catch (SourceException ex) {
             throw new SomeModifiersUnresolvedException(currentPhase, sourceId, ex);
+        } finally {
+            RecursiveObjectLeaker.cleanup();
         }
 
         return new EffectiveSchemaContext(rootStatements, rootEffectiveStatements);