Bug description
The Javadoc of FixedLengthTokenizer#setColumns states: "If the last range is open, then the rest of the line is read into that column (irrespective of the strict flag setting)." However, calculateMaxRange only marks the tokenizer as open when the unbounded range's min is strictly greater than the running max seen so far:
upperBound = range.getMin();
if (upperBound > maxRange) {
open = true;
}
Since maxRange is initialized to ranges[0].getMin(), a single open-ended column — setColumns(new Range(1)), i.e. "read the whole line into one field" — never sets open, and any range order where the unbounded range's min is not greater than the max seen so far (ranges are documented as order-independent, e.g. new Range(11), new Range(1, 10)) has the same problem. Longer lines then fail with IncorrectLineLengthException in strict mode even though the open range should absorb the rest of the line.
Environment
Spring Batch main at cb69762 (6.0.x), also reproducible on 5.x. JDK 21.
Steps to reproduce
FixedLengthTokenizer tokenizer = new FixedLengthTokenizer();
tokenizer.setColumns(new Range(1));
tokenizer.tokenize("H1 12345678 1234567890");
// IncorrectLineLengthException: Line is longer than max range 1
Expected behavior
The open-ended range absorbs the rest of the line regardless of where the unbounded range's min falls relative to the other ranges, as documented. I will submit a PR with a fix and tests.
Bug description
The Javadoc of
FixedLengthTokenizer#setColumnsstates: "If the last range is open, then the rest of the line is read into that column (irrespective of the strict flag setting)." However,calculateMaxRangeonly marks the tokenizer as open when the unbounded range's min is strictly greater than the running max seen so far:Since
maxRangeis initialized toranges[0].getMin(), a single open-ended column —setColumns(new Range(1)), i.e. "read the whole line into one field" — never setsopen, and any range order where the unbounded range's min is not greater than the max seen so far (ranges are documented as order-independent, e.g.new Range(11), new Range(1, 10)) has the same problem. Longer lines then fail withIncorrectLineLengthExceptionin strict mode even though the open range should absorb the rest of the line.Environment
Spring Batch
mainatcb69762(6.0.x), also reproducible on 5.x. JDK 21.Steps to reproduce
Expected behavior
The open-ended range absorbs the rest of the line regardless of where the unbounded range's min falls relative to the other ranges, as documented. I will submit a PR with a fix and tests.