Repository navigation
fix: keep at most 100 schema errors and release the inflater on every path - #19
Merged
marevol merged 1 commit intoNov 16, 2026
Conversation
… path XMLErrorAccumulatorHandler kept one SAXParseException for every error the schema check reported. A message is checked against the schema before its signature, and a document with tens of thousands of invalid elements held tens of megabytes until the check finished. The handler now keeps the first 100 errors; hasError() is unchanged. Util.base64decodedInflated skipped Inflater#end() when inflating failed, which left the native memory of the inflater to the garbage collector. Release it in a finally block.
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.
Stacked on #18 (the base is that branch; retarget to
mainonce #18 is merged).Summary
Two costs that an anonymous message can raise before its signature is checked.
XMLErrorAccumulatorHandlerkept oneSAXParseExceptionper error the schema check reported. A document with tens of thousands of invalid elements held tens of megabytes until the check finished, andUtil.validateXMLthen built a string of all of them before cutting it to 1,000 characters for the log. The handler now keeps the first 100 errors, which say what is wrong with the document.hasError()and the validation result are unchanged.Util.base64decodedInflatedskippedInflater#end()when inflating failed, so the native memory of the inflater waited for the garbage collector. It is released in afinallyblock now.Test
UtilsTest#testSchemaErrorsAreKeptUpToALimit: a response with 3,000 invalid elements leaves 100 errors,hasError()is true andvalidateXMLis false. Without the limit the test sees 3,000.UtilsTest#testBase64decodedInflatedOfBytesThatAreNotDeflated: the fallback for a payload that is not deflated data is unchanged.coremodule's 430 tests and thetoolkitmodule's 93 tests pass.