Menu

#176 Improper use of "new String(byte[])"

open
5
2005-10-24
2005-10-24
Vincent G.
No

In FilePID, (and in MemoryPID, and in DatabasePID),
"short_value_str()" and "short_str()", improperly use
"new String(byte[])".

"new String(byte[])" transform the byte array to a
String accordingly to the current system charset
encoding. If the charset encoding is 'en_US.ASCII' or
'C', any byte greater than 127 (or lower than zero), is
converted to a '?' character.

This is not what you want, as the PID contains any
values, and you use that String as key of "_cache"
Hashtable.

Note that you also use directly "New String(byte[])" in
"DataManager" instead of having a generic method to
convert PID byte arrays to Strings.

A possible fix might be to convert byte array to a
hexadecimal String representation for those methods and
as key of "DataManager._cache" Hashtable.

Discussion


Log in to post a comment.

Monday.com Logo