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 2323import org .junit .Before ;
2424import org .junit .Test ;
2525
26+ import java .util .Iterator ;
2627import java .util .List ;
2728
2829import static org .hamcrest .MatcherAssert .assertThat ;
@@ -110,4 +111,22 @@ public void giveMultipleSegmentsThatGeneratesMultipleBufferFullErrorsThenIsAbleT
110111 List <String > tokens = toList (sut .extract ("ccc\n ddd\n " ));
111112 assertEquals (List .of ("ccccc" , "ddd" ), tokens );
112113 }
114+
115+ @ Test
116+ public void givenFragmentThatHasTheSecondTokenOverrunsSizeLimitThenAnErrorIsThrown () {
117+ Iterable <String > tokensIterable = sut .extract ("aaaa\n bbbbbbbbbbb\n ccc\n " );
118+ Iterator <String > tokensIterator = tokensIterable .iterator ();
119+
120+ // first token length = 4, it's ok
121+ assertEquals ("aaaa" , tokensIterator .next ());
122+
123+ // second token is an overrun, length = 11
124+ Exception exception = assertThrows (IllegalStateException .class , () -> {
125+ tokensIterator .next ();
126+ });
127+ assertThat (exception .getMessage (), containsString ("input buffer full" ));
128+
129+ // third token resumes
130+ assertEquals ("ccc" , tokensIterator .next ());
131+ }
113132}
You can’t perform that action at this time.
0 commit comments