When trying to re-use a Nokogiri::XML::Schema object for validating multiple Nokogiri::XML documents, the MRI and JRuby implementations behave differently. The JRuby implementation reports errors encountered in previous validation, while the MRI version does not.
Please see https://gist.github.com/ylansegal/eac88b27f5369b4f8ca7 for a recreation of the problem. It essentially validates a known good document, then a bad document and then a good document again against the same Schema object. In MRI, the last validation does not report errors (which is what I would expect). In JRuby it reports the errors from the previously validated document.
By the way, I encountered this error because the ruby-saml gem tries to memoize the schema to avoid reading from disk each time:
https://github.com/onelogin/ruby-saml/blob/master/lib/onelogin/ruby-saml/saml_message.rb#L26
When trying to re-use a
Nokogiri::XML::Schemaobject for validating multipleNokogiri::XMLdocuments, the MRI and JRuby implementations behave differently. The JRuby implementation reports errors encountered in previous validation, while the MRI version does not.Please see https://gist.github.com/ylansegal/eac88b27f5369b4f8ca7 for a recreation of the problem. It essentially validates a known good document, then a bad document and then a good document again against the same
Schemaobject. In MRI, the last validation does not report errors (which is what I would expect). In JRuby it reports the errors from the previously validated document.By the way, I encountered this error because the ruby-saml gem tries to memoize the schema to avoid reading from disk each time:
https://github.com/onelogin/ruby-saml/blob/master/lib/onelogin/ruby-saml/saml_message.rb#L26