You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Ajay Kumar (JIRA)" <ji...@apache.org> on 2017/12/06 23:10:00 UTC

[jira] [Comment Edited] (HADOOP-14914) Change to a safely casting long to int.

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

Ajay Kumar edited comment on HADOOP-14914 at 12/6/17 11:09 PM:
---------------------------------------------------------------

[~yufeigu], thanks for kicking Jenkins run.
TestUnbuffer and TestContainerLaunch are failing without the patch as well. Other two passed locally.


was (Author: ajayydv):
[~yufeigu], thanks for submitting the patch.
TestUnbuffer and TestContainerLaunch are failing without the patch as well. Other two passed locally.

> Change to a safely casting long to int. 
> ----------------------------------------
>
>                 Key: HADOOP-14914
>                 URL: https://issues.apache.org/jira/browse/HADOOP-14914
>             Project: Hadoop Common
>          Issue Type: Improvement
>    Affects Versions: 3.1.0
>            Reporter: Yufei Gu
>            Assignee: Ajay Kumar
>         Attachments: HADOOP-14914.001.patch, HADOOP-14914.002.patch
>
>
> There are bunches of casting long to int like this:
> {code}
> long l = 123
> int i = (int) l;
> {code}
> This is not a safe cast. if l is greater than Integer.MAX_VALUE, i would be negative, which is an unexpected behavior. We probably at least want to throw an exception in that case. I suggest to use {{Math.toIntExact(longValue)}} to replace them, which throws an exception if the value overflows an int. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org