[
https://issues.apache.org/jira/browse/MAPREDUCE-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Allen Wittenauer resolved MAPREDUCE-2827.
-----------------------------------------
Resolution: Incomplete
Closing this as stale.
> Test code can create Integer.MIN_INT when trying to create a random
> non-negative integer
> ----------------------------------------------------------------------------------------
>
> Key: MAPREDUCE-2827
> URL: https://issues.apache.org/jira/browse/MAPREDUCE-2827
> Project: Hadoop Map/Reduce
> Issue Type: Bug
> 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 was sent by Atlassian JIRA
(v6.2#6252)