stevedlawrence opened a new pull request, #1122: URL: https://github.com/apache/daffodil/pull/1122
When calling withDistinguishedRootNode, we copy the ProcessorFactory replacing the root spec with the new node. But when we do this, also copy the existing SchemaSet. However, this SchemaSet was created with the previous root spec, which means withDistinguishedRootNode doesn't actually do anything. Instead, the only workaround is to pass in the root name/namspace to the compileSource/File function, so that the root spec is available when the SchemaSet is created. To fix this, this modifies withDistinguishedRootNode to not copy the SchemaSet, so a new SchemaSet will be created and initialized with the correct root spec. Each ProcessorFactory now has a unique SchemaSet instance with the correct root name and namespace. This also discovered cases in the Compiler.compileSourceInternal and JAPI/SAPI compileFile functions where they called isError on the newly created ProcessorFactory before returning it to the caller. This meant that the SchemaSet inside the ProcessorFactory would be forced to be created, even though it might never be used, like in the case of withDistinguishedRootNode being called and a different SchemaSet being created. Really the isError function should only ever be called by the user when they are ready for the object to be evaluated, and not forced by Daffodil internals. This ensures we avoid unnecessary until the user is ready, since isError is what eventually causes lazy vals to be evaluated. However, this does mean that if a user doesn't call isError they might get exceptions/assertions, but this is well documented in the JAPI/SAPI that this function must be called first before calling other functions. This also means that some debug logging that relies on knowing that status of isError must be moved elsewhere, since the user might not have called isError yet. This also discovered instances in the TDMLRunner and CLI where we queried diagnostics before checking isError--isError should always be done first. DAFFODIL-2864, DAFFODIL-697 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
