-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide better exception when unable to resolve class while deserializing rulebase #264
Comments
Note that this error could occur with various scenarios that lead to the record map constructor function not being resolvable. In this case, my understanding from the issue and offline conversations with @EthanEChristian is that it occurred from serializing with one version of an application consuming Clara and deserializing with a newer version of that application, but it could also occur if, say, the namespace needed simply wasn't required even if the needed namespace and version were on the classpath. Ideally we'd handle the nil in such a way that a meaningful exception saying something like "Couldn't resolve the needed record constructor function map->YourRecordNameHere." However, since deserialization involves lots of calls to this record handler any error checking will need to be done in a very performance-sensitive way. |
A few notes:
Basically, Clara durability is about moving a rulebase and working memory from point A to point B "across the wire" as a means to distribute where the rules can be ran and to store sessions to "disk" when needed in something like a per-client request webserver environment. I agree this error is not the best. However, I'll mention that this form of durability is not that different from something like Java serialization. Java serialization also fails with some really confusing errors for similar reasons. Adding error handling at such fine-grained levels like this is going to be a tedious task. It also is a performance concern as @WilliamParker mentions above. One approach that could be taken is to "stamp" the serialized images with a version requirement of some sort. This would be similar to the Java classfile format has a version that is checked when a JVM loads it. The JVM fails to load the class if the version is out of the supported range (typically when it is newer than the JVM's current version). More granular approaches could be to stamp a version per record type, this would be similar to Java serialization's There can be more problems with crossing versions than records. Functions are serialized mostly via a var name (symbolic reference) that is expected to exists, followed by the arguments to the function. If the function's arity were changed in an incompatible way later (not a great practice, but common), then these function calls would eventually fail at deserialization or later when used. Issues like this get increasingly difficult to reasonably try to error handle in the Clara durability layer. |
…ass while deserializing rulebase
When a rulebase or session is serialized with a newer version of rules that may contain new records, if you try and deserialize the rulebase with older version of the rules file that doesn't contain these classes.
In the case described above while deserializing there is a null pointer thrown when trying to resolve the constructor symbol in the read-record function.
In this scenario i would expect the deserialization to fail, but provide a better exception when the constructor for the missing record.
Typically this sort of error would effect deserializing a session, however can effect the rulebase when a custom-fact-type function is provided and a record is used as the type in a condition for a rule. ex.
The text was updated successfully, but these errors were encountered: