You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@htrace.apache.org by "Colin Patrick McCabe (JIRA)" <ji...@apache.org> on 2014/12/31 20:53:13 UTC

[jira] [Commented] (HTRACE-40) MilliSpanDeserializer throws NumberFormatException when Span has negative Long value

    [ https://issues.apache.org/jira/browse/HTRACE-40?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14262391#comment-14262391 ] 

Colin Patrick McCabe commented on HTRACE-40:
--------------------------------------------

Very good find, [~longzhouwk].

{code}
286	  private static long parseUnsignedLong(String s) {
287	    return new BigInteger(s, 16).longValue();
288	  }
{code}
Maybe name this "parseUnsignedHexLong"

+1, can fix up on commit if you want

> MilliSpanDeserializer throws NumberFormatException when Span has negative Long value
> ------------------------------------------------------------------------------------
>
>                 Key: HTRACE-40
>                 URL: https://issues.apache.org/jira/browse/HTRACE-40
>             Project: HTrace
>          Issue Type: Bug
>            Reporter: Long Zhou
>            Assignee: Long Zhou
>         Attachments: HTRACE-40.001.patch
>
>
> When a negative long (e.g. -1L) is converted to hex string (ffff ffff ffff ffff), Long.parseLong treats it as a positive number that overflows, and the function throws NumberFormatException.
> The fix is to use java.math.BigInteger to parse it.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)