Conversation
| /** safes repeating a few lines ... */ | ||
| private Integer conect_helper (String line,int start,int end) { | ||
| if (line.length() < end) return null; | ||
| if (line.length() < start || line.length() < end) return null; |
There was a problem hiding this comment.
I am a bit confused because for this function I assume that by definition start < end, and therefore checking line.length() < end should be sufficient here. @r614 do you know of a case where this is not true? Maybe the solution would be to check that indeed start < end always and track when this is problematic during parsing.
@Sheraf-DNG could you provide your test case so that we include it as a unit test and make sure it is fixed?
There was a problem hiding this comment.
This was over ago, I can't remember it sorry... I'm myself baffled by the solution I proposed :/ but yep there was a StringOutOfBound trrown from this function, and adding this seemed to solve it in my tests...
There was a problem hiding this comment.
@lafita I agree with you, but I think it would also depend on how BioJava wants to handle specs.
I think the possible ways you get this error is if:
- (start > end ) < line length
- end < line length < start
- start < line length < end
If any of those cases are possible, or users can use the method then I think adding a checkpoint won't be a bad idea, but if the function is used internally then I don't think it would really matter, considering it passes all tests so far.
|
I'll close this. The conclusion seems to be that this is a private function and does not need extra input validation checks. |
Added the recommended solution for the line length bug from Issue #760