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

Roger Riggs rriggs at openjdk.java.net
Tue Apr 6 13:56:25 UTC 2021


On Tue, 6 Apr 2021 13:07:58 GMT, Conor Cleary <ccleary at openjdk.org> wrote:

>> test/jdk/java/nio/channels/DatagramChannel/SRTest.java line 228:
>> 
>>> 226:                 SocketAddress sa = dc.receive(bb);
>>> 227:                 bb.flip();
>>> 228:                 CharBuffer cb = StandardCharsets.US_ASCII.newDecoder().decode(bb);
>> 
>> If a charset is used, then it should be used consistently - in both classic and nio readers and writers.
>> That is, whenever `String::getBytes` is called or `new String(byte[])` is called.
>
> Makes sense, I think I will opt for using `US_ASCII` across all of the classic and nio readers/writers.

Using an 8-bit charset might be a better choice, US_ASCII is only 7bit and might produce some unmappable characters.
ISO_8859_1 would be a better choice.

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

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


More information about the nio-dev mailing list