[
https://issues.apache.org/jira/browse/HADOOP-3567?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605349#action_12605349
]
Owen O'Malley commented on HADOOP-3567:
---------------------------------------
Please look over the how to contribute page
http://wiki.apache.org/hadoop/HowToContribute and generate a standard patch,
please. You might also consider reusing the same IntWritable instead of
creating a new one each time.
> Test code can create Integer.MIN_INT when trying to create a random
> non-negative integer
> ----------------------------------------------------------------------------------------
>
> Key: HADOOP-3567
> URL: https://issues.apache.org/jira/browse/HADOOP-3567
> Project: Hadoop Core
> Issue Type: Bug
> Affects Versions: 0.17.0
> Reporter: Tim Halloran
> Priority: Minor
>
> Sadly, Math.abs returns Integer.MIN_VALUE when passed Integer.MIN_VALUE Thus
> the code in
> org.apache.hadoop.mapred.TestMapRed appears to need to consider this case.
> Patch below.
> Index: .
> ===================================================================
> --- . (revision 8259)
> +++ . (working copy)
> @@ -97,7 +97,9 @@
> int randomCount = key.get();
>
> for (int i = 0; i < randomCount; i++) {
> - out.collect(new IntWritable(Math.abs(r.nextInt())), new
> IntWritable(randomVal));
> + int collectKey = Math.abs(r.nextInt());
> + if (collectKey == Integer.MIN_VALUE) collectKey = Integer.MAX_VALUE;
> + out.collect(new IntWritable(collectKey), new IntWritable(randomVal));
> }
> }
> public void close() {
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.