Tibor17 commented on code in PR #518: URL: https://github.com/apache/maven-surefire/pull/518#discussion_r848466591
########## surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java: ########## @@ -258,6 +258,56 @@ public void shouldReadString() throws Exception .isEqualTo( "0123456789" ); } + @Test + public void shouldReadStringOverflowOnNewLine() throws Exception + { + StringBuilder s = new StringBuilder( 1025 ); + for ( int i = 0; i < 10; i++ ) + { + s.append( PATTERN1 ); + } + s.append( PATTERN1, 0, 23 ); + s.append( "\u00FA\n" ); // 2-bytes encoded character + LF + + Channel channel = new Channel( s.toString().getBytes( UTF_8 ), s.length() ); + + Mock thread = new Mock( channel, new MockForkNodeArguments(), + Collections.<Segment, ForkedProcessEventType>emptyMap() ); + + Memento memento = thread.new Memento(); + + assertThat( (String) invokeMethod( thread, "readString", memento, 1026 ) ) + .isEqualTo( s.toString() ); + + assertThat ( memento.getByteBuffer().remaining() ) + .isEqualTo( 0 ); + } + + @Test + public void shouldReadStringOverflowOn4BytesEncodedSymbol() throws Exception + { + StringBuilder s = new StringBuilder( 1024 ); Review Comment: I don't know. The point of the unit tests is that you provide them and I would be able to reproduce a test failure with the original code. And I would apply your fix which makes the test green again. This was the process on my side. It;s up to you. The tests are just a kind of language you as contributor want to convince ASF about the whole point of the fix. If it is necessary to write more tests, feel free to do it but then I will undergo the test with verifying failure on the original master code. I found your interesting IT https://github.com/zoltanmeze/surefire-corrupted-channel -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org