validate direction number degree in SobolSequenceGenerator stream parser - #325
Conversation
|
Thanks for the bug fix. Can you add a unit test that fails without the patch. Thank you. |
|
Added testConstructorDegreeTooLarge. It feeds a stream with degree s=60 (BITS is 52), which hits a raw ArrayIndexOutOfBoundsException without the patch and now gives MathParseException. |
|
Hi @aherbert Just a friendly follow-up on this PR. I understand everyone is busy, but I wanted to check whether you've had a chance to review it or if there are any remaining concerns I can help address. Thank you for your time and feedback. |
|
The CI build fails on the new added test: Please fix the test. |
|
sure i'll do that. Thanks |
|
Fixed — the test calls the InputStream constructor which throws IOException, so I declared throws Exception on the method like testConstructor2 does. Builds and passes locally now. |
|
any update? |
|
Closing this pull request due to inactivity |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #325 +/- ##
============================================
+ Coverage 86.54% 87.15% +0.60%
+ Complexity 9787 89 -9698
============================================
Files 532 499 -33
Lines 35516 33465 -2051
Branches 6194 5834 -360
============================================
- Hits 30738 29167 -1571
+ Misses 3518 3172 -346
+ Partials 1260 1126 -134 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
SobolSequenceGenerator.initFromStream reads a per-dimension degree
sfrom the direction-number stream passed to the publicSobolSequenceGenerator(int, InputStream)constructor, then allocatesnew int[s + 1]and writesdirection[d][1..s]even though eachdirection[d]holds onlyBITS + 1entries. A line withs > BITSthrows a raw ArrayIndexOutOfBoundsException ands < 1throws NegativeArraySizeException, instead of the MathParseException this parser uses for every other malformed line. Reject out-of-rangesbefore the allocation so bad input maps to MathParseException like the surrounding token parsing.