Convert NodeInfo.Nothing from a lazy val to an object#1655
Open
stevedlawrence wants to merge 1 commit intoapache:mainfrom
Open
Convert NodeInfo.Nothing from a lazy val to an object#1655stevedlawrence wants to merge 1 commit intoapache:mainfrom
stevedlawrence wants to merge 1 commit intoapache:mainfrom
Conversation
The NodeInfo.Nothing instance has a `children` Delay member that never actually gets evaluated. This is fine and not unexpected since Nothing doesn't really have children and so nothing ever attempts to access or need the member. However, in some cases it is possible for the Nothing val to be referenced in a serialized class (e.g. in a DPath expression object that stores argument types such as fn:round-half-to-even) when creating a saved parser. And because this Nothing has a Delay that is never evaluated, it leads to an "object not initialized" exception, preventing creating a saved parser. To fix this issue, this changes NodeInfo.Nothing from a lazy val to an object. Whether we use a lazy val or an object here really does not make a difference with how we use it, but in Scala lazy vals are serialized while objects are not--Scala only serializes object names which are used to look up and return the singleton instance during deserialization. This allows us to avoid all possible serialization issues, and also changes Nothing to match the same pattern as all the other TypeNodes. DAFFODIL-3079
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The NodeInfo.Nothing instance has a
childrenDelay member that never actually gets evaluated. This is fine and not unexpected since Nothing doesn't really have children and so nothing ever attempts to access or need the member.However, in some cases it is possible for the Nothing val to be referenced in a serialized class (e.g. in a DPath expression object that stores argument types such as fn:round-half-to-even) when creating a saved parser. And because this Nothing has a Delay that is never evaluated, it leads to an "object not initialized" exception, preventing creating a saved parser.
To fix this issue, this changes NodeInfo.Nothing from a lazy val to an object. Whether we use a lazy val or an object here really does not make a difference with how we use it, but in Scala lazy vals are serialized while objects are not--Scala only serializes object names which are used to look up and return the singleton instance during deserialization. This allows us to avoid all possible serialization issues, and also changes Nothing to match the same pattern as all the other TypeNodes.
DAFFODIL-3079