File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
logstash-core/src/test/java/org/logstash/common Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 22
22
import org .junit .Before ;
23
23
import org .junit .Test ;
24
24
25
+ import java .util .Iterator ;
25
26
import java .util .List ;
26
27
27
28
import static org .hamcrest .MatcherAssert .assertThat ;
@@ -109,4 +110,22 @@ public void giveMultipleSegmentsThatGeneratesMultipleBufferFullErrorsThenIsAbleT
109
110
List <String > tokens = toList (sut .extract ("ccc\n ddd\n " ));
110
111
assertEquals (List .of ("ccccc" , "ddd" ), tokens );
111
112
}
113
+
114
+ @ Test
115
+ public void givenFragmentThatHasTheSecondTokenOverrunsSizeLimitThenAnErrorIsThrown () {
116
+ Iterable <String > tokensIterable = sut .extract ("aaaa\n bbbbbbbbbbb\n ccc\n " );
117
+ Iterator <String > tokensIterator = tokensIterable .iterator ();
118
+
119
+ // first token length = 4, it's ok
120
+ assertEquals ("aaaa" , tokensIterator .next ());
121
+
122
+ // second token is an overrun, length = 11
123
+ Exception exception = assertThrows (IllegalStateException .class , () -> {
124
+ tokensIterator .next ();
125
+ });
126
+ assertThat (exception .getMessage (), containsString ("input buffer full" ));
127
+
128
+ // third token resumes
129
+ assertEquals ("ccc" , tokensIterator .next ());
130
+ }
112
131
}
You can’t perform that action at this time.
0 commit comments