RFR: 8264200: java/nio/channels/DatagramChannel/SRTest.java fails intermittently

Conor Cleary ccleary at openjdk.java.net
Tue Apr 6 14:49:27 UTC 2021


On Tue, 6 Apr 2021 14:34:57 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Its case by case, if you don't know how the stream of characters was encoded into a byte stream then you can't reliably decode it back to characters.  For SRTest, it doesn't matter, all the strings I see are ascii.
>> But note that String.getBytes() uses a platform dependent encoding. 
>> Until the platform encoding is UTF-8, its recommended to use String.getBytes(charset).
>> A lot of times UTF-8 is a good guess for operations that convert strings to bytes and back.
>
> As the test is for Datagram send and receive all the data is in byte arrays or equivalent.
> The entire test could be written using only byte arrays (no Strings, Charsets or conversions) and omit that possibility of confusion about what the test is doing.
> (And there's no need to change anything).

Alright then so I will continue to to just use `US_ASCII` in this test as "hello" is mappable with it. Encoding and Decoding the string will be done with `US_ASCII`. Appreciate the feedback guys, thanks!

-------------

PR: https://git.openjdk.java.net/jdk/pull/3354


More information about the nio-dev mailing list