J2DdemoTest.java - Platform default encoding used for process output

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Generic / MacOS / Java 21

      A DESCRIPTION OF THE PROBLEM :
      J2DdemoTest.java line 99 uses `new String(b, 0, n)` which relies on platform default encoding instead of explicit charset specification.

      At line 99, `MyInputStream.run()` converts process output bytes to a String using `new String(byte[], int, int)`, which uses the platform default charset.

      The test logic performs string matching on the decoded output for fixed tokens such as "ERROR" and "Exception" strings in the output at lines 46 and 49.
      Decoding process output without an explicit charset introduces platform-dependent behavior into the test.


      REGRESSION : Last worked in version 21.0.9-oracle

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      N/A - Encoding-dependent behavior.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The test should decode process output in a charset-independent manner.

      ACTUAL -
      The platform default charset is used implicitly when decoding process output.


            Assignee:
            Anupam Dev
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: