You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Marcono1234 (Jira)" <ji...@apache.org> on 2021/01/14 22:56:00 UTC

[jira] [Created] (AMQ-8122) DataByteArrayInputStreamTest.testNonAscii() is faulty

Marcono1234 created AMQ-8122:
--------------------------------

             Summary: DataByteArrayInputStreamTest.testNonAscii() is faulty
                 Key: AMQ-8122
                 URL: https://issues.apache.org/jira/browse/AMQ-8122
             Project: ActiveMQ
          Issue Type: Bug
            Reporter: Marcono1234


It appears the unit test [{{DataByteArrayInputStreamTest.testNonAscii()}}|https://github.com/apache/activemq/blob/1c315db1d1a5432a87e0e43d82d8e926811c6419/activemq-client/src/test/java/org/apache/activemq/util/DataByteArrayInputStreamTest.java#L29] is faulty:
# It loops with {{while(Character.isDefined(test))}}, however the unicode data has gaps, currently with Java 15 the first gap is the code point 888, {{Character.isDefined(888) == false}}.
Therefore this test never tries any higher code points. Looping up to, including {{Character.Character.MAX_CODE_POINT}} might be better.
# Based on the comment next to the variable {{test}}, it appears the author wanted to test supplementary code points as well, however by casting them to {{char}} when creating the String, they are cutting off code points > {{\uFFFF}}. It should instead convert the code point to a String like this:
{code:java}
// Java 11
String toTest = Character.toString(test);
// Java < 11
String toTest = String.valueOf(Character.toChars(test));
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)