You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/04/12 13:54:39 UTC

[GitHub] [maven-surefire] Tibor17 commented on a diff in pull request #518: [SUREFIRE-2058] - Corrupted STDOUT by directly writing to native stream in forked JVM 1 with UTF-8 console logging

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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org