Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public int read(final char[] target, final int targetIndexIn, final int targetLe
while (true) {
if (isBufferMatchAt(suffixMatcher, pos)) {
balance--;
pos++;
pos += suffixMatcher.size();
if (balance == 0) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,22 @@ void testReadMixedBufferLengthsVarLenPlusToNoReplace() throws IOException {
}
}

@Test
void testReadSubstituteVariablesWithSuffixLongerThanTwoCharacters() throws IOException {
final StringSubstitutor substitutor = new StringSubstitutor(values);
final String template = "[[aaa]]>";
substitutor.setVariablePrefix("[[");
substitutor.setVariableSuffix("]]>");

try (Reader reader = createReader(substitutor, template)) {
final int endIndex = template.length() - 1;
final char[] cbuf = new char[endIndex];
final int readCount = reader.read(cbuf);
final String result = new String(cbuf, 0, readCount);
assertEquals("111", result);
}
}

private Reader toReader(final String expectedResult) {
return expectedResult != null ? new StringReader(expectedResult) : new NullReader();
}
Expand Down
Loading