Skip to content

Commit 12e7d68

Browse files
committed
Fixed tests to grab the failure on exceeded size limit on itereation once reached the next separator
1 parent e5c1686 commit 12e7d68

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

logstash-core/src/test/java/org/logstash/common/BufferedTokenizerWithSizeLimitTest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,39 @@ public void givenExtractedThrownLimitErrorWhenFeedFreshDataThenReturnTokenStarti
6969
public void givenExtractInvokedWithDifferentFramingAfterBufferFullErrorTWhenFeedFreshDataThenReturnTokenStartingFromEndOfOffendingToken() {
7070
sut.extract("aaaa");
7171

72+
// it goes to 11 on a sizeLimit of 10, but doesn't trigger the exception till the next separator is reached
73+
sut.extract("aaaaaaa").forEach(s -> {});
74+
75+
Iterable<String> tokenIterable = sut.extract("aa\nbbbb\nccc");
7276
Exception thrownException = assertThrows(IllegalStateException.class, () -> {
73-
sut.extract("aaaaaaa").forEach(s -> {});
77+
// now when querying and the next delimiter is present, the error is raised
78+
tokenIterable.forEach(s -> {});
7479
});
7580
assertThat(thrownException.getMessage(), containsString("input buffer full"));
7681

77-
List<String> tokens = toList(sut.extract("aa\nbbbb\nccc"));
82+
// the iteration on token can proceed
83+
List<String> tokens = toList(tokenIterable);
7884
assertEquals(List.of("bbbb"), tokens);
7985
}
8086

8187
@Test
8288
public void giveMultipleSegmentsThatGeneratesMultipleBufferFullErrorsThenIsAbleToRecoverTokenization() {
8389
sut.extract("aaaa");
8490

91+
// it goes to 11 on a sizeLimit of 10, but doesn't trigger the exception till the next separator is reached
92+
sut.extract("aaaaaaa").forEach(s -> {});
93+
94+
Iterable<String> tokenIterable = sut.extract("aa\nbbbbbbbbbbb\ncc");
95+
8596
//first buffer full on 13 "a" letters
8697
Exception thrownException = assertThrows(IllegalStateException.class, () -> {
87-
sut.extract("aaaaaaa").forEach(s -> {});
98+
tokenIterable.forEach(s -> {});
8899
});
89100
assertThat(thrownException.getMessage(), containsString("input buffer full"));
90101

91102
// second buffer full on 11 "b" letters
92103
Exception secondThrownException = assertThrows(IllegalStateException.class, () -> {
93-
sut.extract("aa\nbbbbbbbbbbb\ncc");
104+
tokenIterable.forEach(s -> {});
94105
});
95106
assertThat(secondThrownException.getMessage(), containsString("input buffer full"));
96107

0 commit comments

Comments
 (0)