Skip to content

Convert NodeInfo.Nothing from a lazy val to an object#1655

Open
stevedlawrence wants to merge 1 commit intoapache:mainfrom
stevedlawrence:daffodil-3079-nothing-serialization
Open

Convert NodeInfo.Nothing from a lazy val to an object#1655
stevedlawrence wants to merge 1 commit intoapache:mainfrom
stevedlawrence:daffodil-3079-nothing-serialization

Conversation

@stevedlawrence
Copy link
Copy Markdown
Member

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant