@Lolodomo I have a situation that I’m not quite sure how to handle. RuleSerializer.setRulesToBeSerialized() can encounter rules that can’t be serialized, for various reasons (if the rule has shared context, isn’t conforming to the limitations of DSL if it’s the DSL serializer, etc.).
I’ve looked at Things and Items, and there’s basically no way to handle a “failure to serialize” there. I guess all instances can be serialized, unlike with rules.
The question is, if there are multiple rules “submitted”, and just one or some that don’t qualify, do I “reject” the whole “batch”, or only those that don’t qualify? And, how do I communicate back the details of why they can’t be serialized?
I can just make the method throw an Exception, but it won’t enable a very detailed feedback, and certainly not a “per rule feedback”.
There’s also the relationship with generateFormat(), once you call the former, the models will be created and these won’t be free’d until you call generateFormat(). In a way, it’s like a try-with-resources, where the final operation releases any allocated resources. But, it must be clear then, in case of a failure to add rules to serialization, do you still have to call generateFormat()?
In a way, it would be better if these interfaces extended AutoCloseable, and that close() was what actually released the resources. That would make it work with try-with-resources, but it can’t actually be done, since, as it is now, the caller must keep track of the modelName so that the converter knows “what to release”.
All in all, I’m not sure I understand why serialization is split into a multi-step process, it does increase that chance of resource leaks somewhat. But, regardless of this, I need to “inject” error handling/feedback into all this somehow.