Repository navigation
Conversation
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.
Observed on master with the default formats:
Two separate paths let malformed text through.
parse(String)is documented to throw MathParseException, but both classes detect failure withparsePosition.getIndex() == 0. TheparseFixedstringfailure paths inparse(String, ParsePosition)leave the index past whatever was consumed, so the caller gets null instead of the exception. ComplexFormat already testsresult == null; the same test is now used here.In RealMatrixFormat, a row that has its prefix but no component is treated as the end of the matrix, and the unconsumed
}is then matched as the matrix suffix. The empty row disappears and the result has the wrong dimensions. Once a row has been opened after earlier rows it now needs a component, so it fails like any other invalid component. Formats with an empty row prefix have no opened row to reject and still accept a closing row separator; a test pins that.Regression tests in RealMatrixFormatAbstractTest and RealVectorFormatAbstractTest fail without the patch.
mvn clean verifyon commons-math-legacy and its dependencies passes on JDK 17 (3278 tests in legacy), as does checkstyle:check. This is separate from #338, which fixed the CompositeFormat cursor helpers.