yrodiere commented on PR #506:
URL: https://github.com/apache/maven-surefire/pull/506#issuecomment-1088329572

   @Tibor17 I would have, but the bug only occurs the message is an empty 
string, unlike the existing test, and I assumed this would be too big of a 
change? Not testing the nominal case with both a message and a test run ID 
seemed unwise, but what do I know :)
   
   I suspect the reason we don't get the bug with a non-empty message is that 
we over-allocate space in the buffer for the message: length * <maximum 
possible size of UTF-8 characters>:
   
   
https://github.com/apache/maven-surefire/blob/79db90338fb474f91c76991388a35bc412ee1d46/surefire-api/src/main/java/org/apache/maven/surefire/api/stream/AbstractStreamEncoder.java#L206
   
   In the case of UTF-8 the max bytes per char is `3.0f`, while most characters 
are just 1 byte, so this leaves a few extra bytes in the buffer that can be 
used for something else, and this over-allocation ends up "compensating" the 
bug.
   
   I adjusted the test name and added a comment to make this clear.
   
   Of course if you just wanted me to keep the testing code and shove it into 
the existing test method, I can do that.


-- 
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

Reply via email to