소스 검색

HADOOP-6103. Clones the classloader as part of Configuration clone. Contributed by Amareshwari Sriramadasu.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@806430 13f79535-47bb-0310-9956-ffa450edef68
Devaraj Das 15 년 전
부모
커밋
0a8e65c23b
3개의 변경된 파일21개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 0
      CHANGES.txt
  2. 7 0
      src/java/org/apache/hadoop/conf/Configuration.java
  3. 11 4
      src/test/core/org/apache/hadoop/conf/TestConfiguration.java

+ 3 - 0
CHANGES.txt

@@ -928,6 +928,9 @@ Trunk (unreleased changes)
     HADOOP-6192. Fix Shell.getUlimitMemoryCommand to not rely on Map-Reduce
     specific configs. (acmurthy) 
 
+    HADOOP-6103. Clones the classloader as part of Configuration clone.
+    (Amareshwari Sriramadasu via ddas)
+
 Release 0.20.1 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 7 - 0
src/java/org/apache/hadoop/conf/Configuration.java

@@ -243,6 +243,9 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
     synchronized(Configuration.class) {
       REGISTRY.put(this, null);
     }
+    this.classLoader = other.classLoader;
+    this.loadDefaults = other.loadDefaults;
+    setQuietMode(other.getQuietMode());
   }
   
   /**
@@ -1373,6 +1376,10 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
     this.quietmode = quietmode;
   }
 
+  synchronized boolean getQuietMode() {
+    return this.quietmode;
+  }
+  
   /** For debugging.  List non-default properties to the terminal and exit. */
   public static void main(String[] args) throws Exception {
     new Configuration().writeXml(System.out);

+ 11 - 4
src/test/core/org/apache/hadoop/conf/TestConfiguration.java

@@ -21,10 +21,6 @@ import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.DataInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.DataOutputStream;
 import java.util.ArrayList;
 import java.util.Random;
 
@@ -401,6 +397,17 @@ public class TestConfiguration extends TestCase {
     assertFalse(conf.iterator().hasNext());
   }
 
+  public static class Fake_ClassLoader extends ClassLoader {
+  }
+
+  public void testClassLoader() {
+    Configuration conf = new Configuration(false);
+    conf.setQuietMode(false);
+    conf.setClassLoader(new Fake_ClassLoader());
+    Configuration other = new Configuration(conf);
+    assertTrue(other.getClassLoader() instanceof Fake_ClassLoader);
+  }
+  
   public static void main(String[] argv) throws Exception {
     junit.textui.TestRunner.main(new String[]{
       TestConfiguration.class.getName()