You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-issues@hadoop.apache.org by "Eli Collins (JIRA)" <ji...@apache.org> on 2011/08/11 20:40:27 UTC

[jira] [Moved] (MAPREDUCE-2827) Test code can create Integer.MIN_INT when trying to create a random non-negative integer

     [ https://issues.apache.org/jira/browse/MAPREDUCE-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eli Collins moved HADOOP-3567 to MAPREDUCE-2827:
------------------------------------------------

    Affects Version/s:     (was: 0.17.0)
                  Key: MAPREDUCE-2827  (was: HADOOP-3567)
              Project: Hadoop Map/Reduce  (was: Hadoop Common)

> 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 is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira