فهرست منبع

HADOOP-3377. Remove TaskRunner::replaceAll and replace with equivalent
String::replace. Contributed by Brice Arnould.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@656904 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 سال پیش
والد
کامیت
d4433d4f6a
2فایلهای تغییر یافته به همراه4 افزوده شده و 31 حذف شده
  1. 3 0
      CHANGES.txt
  2. 1 31
      src/java/org/apache/hadoop/mapred/TaskRunner.java

+ 3 - 0
CHANGES.txt

@@ -143,6 +143,9 @@ Trunk (unreleased changes)
     HADOOP-3013. Add corrupt block reporting to fsck.
     (lohit vijayarenu via cdouglas)
 
+    HADOOP-3377. Remove TaskRunner::replaceAll and replace with equivalent
+    String::replace. (Brice Arnould via cdouglas)
+
   OPTIMIZATIONS
 
     HADOOP-3274. The default constructor of BytesWritable creates empty 

+ 1 - 31
src/java/org/apache/hadoop/mapred/TaskRunner.java

@@ -294,7 +294,7 @@ abstract class TaskRunner extends Thread {
       //  </property>
       //
       String javaOpts = conf.get("mapred.child.java.opts", "-Xmx200m");
-      javaOpts = replaceAll(javaOpts, "@taskid@", taskid.toString());
+      javaOpts = javaOpts.replace("@taskid@", taskid.toString());
       String [] javaOptsSplit = javaOpts.split(" ");
       
       // Add java.library.path; necessary for loading native libraries.
@@ -428,36 +428,6 @@ abstract class TaskRunner extends Thread {
     }
   }
 
-  /**
-   * Replace <code>toFind</code> with <code>replacement</code>.
-   * When hadoop moves to JDK1.5, replace this method with
-   * String#replace (Of is commons-lang available, replace with
-   * StringUtils#replace). 
-   * @param text String to do replacements in.
-   * @param toFind String to find.
-   * @param replacement String to replace <code>toFind</code> with.
-   * @return A String with all instances of <code>toFind</code>
-   * replaced by <code>replacement</code> (The original
-   * <code>text</code> is returned if <code>toFind</code> is not
-   * found in <code>text<code>).
-   */
-  private static String replaceAll(String text, final String toFind,
-                                   final String replacement) {
-    if (text ==  null || toFind ==  null || replacement ==  null) {
-      throw new IllegalArgumentException("Text " + text + " or toFind " +
-                                         toFind + " or replacement " + replacement + " are null.");
-    }
-    int offset = 0;
-    for (int index = text.indexOf(toFind); index >= 0;
-         index = text.indexOf(toFind, offset)) {
-      offset = index + toFind.length();
-      text = text.substring(0, index) + replacement +
-        text.substring(offset);
-        
-    }
-    return text;
-  }
-
   /**
    * Run the child process
    */