Browse Source

HADOOP-1393. Remove a potential unexpected negative number for uses of random number generator. Contributed by Owen.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@540326 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
101bacbce4

+ 3 - 0
CHANGES.txt

@@ -39,6 +39,9 @@ Trunk (unreleased changes)
  12. HADOOP-1364.  Fix various inconsistent synchronization issues.
      (Devaraj Das via cutting)
 
+ 13. HADOOP-1393.  Remove a potential unexpected negative number from
+     uses of random number generator. (omalley via cutting)
+
 
 Branch 0.13 (unreleased changes)
 

+ 3 - 1
src/java/org/apache/hadoop/mapred/JobClient.java

@@ -271,7 +271,9 @@ public class JobClient extends ToolBase implements MRConstants  {
     //
 
     // Create a number of filenames in the JobTracker's fs namespace
-    Path submitJobDir = new Path(job.getSystemDir(), "submit_" + Integer.toString(Math.abs(r.nextInt()), 36));
+    Path submitJobDir = new Path(job.getSystemDir(), "submit_" + 
+                                 Integer.toString(r.nextInt(Integer.MAX_VALUE), 
+                                                  36));
     Path submitJobFile = new Path(submitJobDir, "job.xml");
     Path submitJarFile = new Path(submitJobDir, "job.jar");
     Path submitSplitFile = new Path(submitJobDir, "job.split");

+ 1 - 1
src/java/org/apache/hadoop/mapred/LocalJobRunner.java

@@ -188,7 +188,7 @@ class LocalJobRunner implements JobSubmissionProtocol {
     }
     
     private String newId() {
-      return Integer.toString(Math.abs(random.nextInt()), 36);
+      return Integer.toString(random.nextInt(Integer.MAX_VALUE), 36);
     }
 
     // TaskUmbilicalProtocol methods