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
This commit is contained in:
Devaraj Das 2009-08-21 06:59:45 +00:00
parent 1f3337996e
commit 0a8e65c23b
3 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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()