Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-2076

BufferOverflowException when encoding message with null runMode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0-M6
    • 3.0.0-M7
    • Maven Surefire Plugin
    • None

    Description

      Per #issuecomment-1099231382, #issuecomment-1099706229, #pullrequestreview-951134938 and #issuecomment-1108371215

      RunMode can be null causing BufferOverflowException when encoding message.
      Related to similar issue with null testIds: SUREFIRE-2056

      AbstractStreamEncoder#encodeHeader stores runMode in at least 3 bytes:

      • 1-byte length
      • 1-byte delimiter
      • length-bytes runMode
      • 1-byte delimiter

      In case of null runMode the encoded part becomes 0:: (exactly 3 bytes length)

      The issue is that AbstractStreamEncoder#estimateBufferLength is not expecting/couting any bytes for runMode part in case of null runMode.
      This results in in BufferOverflowException becase the byte size of the message is underestimated.

      Exception thrown:

      java.nio.BufferOverflowException
      	at java.nio.Buffer.nextPutIndex(Buffer.java:547)
      	at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:172)
      	at org.apache.maven.surefire.api.stream.AbstractStreamEncoder.encodeString(AbstractStreamEncoder.java:127)
      	at org.apache.maven.surefire.api.stream.AbstractStreamEncoder.encodeStringData(AbstractStreamEncoder.java:171)
      	at org.apache.maven.surefire.api.stream.AbstractStreamEncoder.encode(AbstractStreamEncoder.java:157)
      	at org.apache.maven.surefire.booter.spi.EventChannelEncoder.encodeMessage(EventChannelEncoder.java:398)
      	at org.apache.maven.surefire.booter.spi.EventChannelEncoder.setOutErr(EventChannelEncoder.java:188)
      	at org.apache.maven.surefire.booter.spi.EventChannelEncoder.testOutput(EventChannelEncoder.java:183)
      	at org.apache.maven.surefire.api.booter.ForkingRunListener.writeTestOutput(ForkingRunListener.java:113)
      	at org.apache.maven.surefire.api.booter.ForkingRunListener.writeTestOutput(ForkingRunListener.java:44)
      	at org.apache.maven.surefire.common.junit4.JUnit4RunListener.writeTestOutput(JUnit4RunListener.java:235)
      	at org.apache.maven.surefire.api.report.ConsoleOutputCapture$ForwardingPrintStream.println(ConsoleOutputCapture.java:144)
      

      Attachments

        Issue Links

          Activity

            People

              tibordigana Tibor Digana
              zoltan.meze Zoltan Meze
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: