[
https://issues.apache.org/jira/browse/ZOOKEEPER-2763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15980824#comment-15980824
]
Brandon Berg edited comment on ZOOKEEPER-2763 at 4/24/17 8:04 AM:
------------------------------------------------------------------
Not a reviewer, so I don't think I have a say here, but just to give my
opinion: This mostly looks good, but I'm not a huge fan of the way the '#' is
added via String concatenation. This reallocates another potentially very large
buffer and copies the whole hex string just to prepend a single hash character.
The approach I suggested in my last comment (passing a prefix in as an argument
to toHexString()) avoids the reallocation and copy by allocating space for it
in the original StringBuilder.
Granted, AFAIK this is only used in debug logging, and the whole thing is
network IO bounded, so maybe it doesn't really matter anyway, but it's an easy
fix that gives a free performance improvement.
was (Author: bberg):
Not a reviewer, so I don't think I have a say here, but just to give my
opinion: This mostly looks good, but I'm not a huge fan of the way the '#' is
added via String concatenation. This reallocates another potentially very large
buffer and copies the whole hex string just to prepend a single hash character.
The approach I suggested in my last comment (passing a prefix in as an argument
to toHexString()) avoids the reallocation and copy by allocating space for it
in the original StringBuilder.
> Utils.toCsvBuffer() omits leading 0 for bytes < 0x10
> ----------------------------------------------------
>
> Key: ZOOKEEPER-2763
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2763
> Project: ZooKeeper
> Issue Type: Bug
> Components: jute
> Affects Versions: 3.5.2
> Reporter: Brandon Berg
> Assignee: Alburt Hoffman
> Priority: Minor
>
> org.apache.jute.Utils.toCsvBuffer(), which converts a byte array to a string
> containing the hex representation of that byte array, omits the leading zero
> for any byte less than 0x10, due to its use of Integer.toHexString, which has
> the same behavior.
> https://github.com/apache/zookeeper/blob/master/src/java/main/org/apache/jute/Utils.java#L234
> One consequence of this is that the hex strings printed by
> ClientCnxn.Packet.toString(), used in the debug logging for
> ClientCnxn.readResponse(), cannot be parsed to determine the result of a
> Zookeeper request from client debug logs.
> Utils.toXmlBuffer() appears to have the same issue.
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)