Revert "HADOOP-11274. ConcurrentModificationException in Configuration Copy Constructor. Contributed by Junping Du."

This reverts commit 16b3482467.
This commit is contained in:
Jing Zhao 2014-11-06 18:27:59 -08:00
parent ae71a671a3
commit ba0a42cf67
2 changed files with 38 additions and 46 deletions

View File

@ -910,9 +910,6 @@ Release 2.6.0 - UNRELEASED
HADOOP-11253. Hadoop streaming test TestStreamXmlMultipleRecords fails on HADOOP-11253. Hadoop streaming test TestStreamXmlMultipleRecords fails on
Windows. (Varun Vasudev via wheat9) Windows. (Varun Vasudev via wheat9)
HADOOP-11274. ConcurrentModificationException in Configuration Copy Constructor.
(Junping Du via jing9)
BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS
HADOOP-10734. Implement high-performance secure random number sources. HADOOP-10734. Implement high-performance secure random number sources.

View File

@ -690,8 +690,8 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Configuration(Configuration other) { public Configuration(Configuration other) {
synchronized(other) {
this.resources = (ArrayList<Resource>) other.resources.clone(); this.resources = (ArrayList<Resource>) other.resources.clone();
synchronized(other) {
if (other.properties != null) { if (other.properties != null) {
this.properties = (Properties)other.properties.clone(); this.properties = (Properties)other.properties.clone();
} }
@ -702,14 +702,14 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
this.updatingResource = new HashMap<String, String[]>(other.updatingResource); this.updatingResource = new HashMap<String, String[]>(other.updatingResource);
this.finalParameters = new HashSet<String>(other.finalParameters); this.finalParameters = new HashSet<String>(other.finalParameters);
this.classLoader = other.classLoader;
this.loadDefaults = other.loadDefaults;
setQuietMode(other.getQuietMode());
} }
synchronized(Configuration.class) { synchronized(Configuration.class) {
REGISTRY.put(this, null); REGISTRY.put(this, null);
} }
this.classLoader = other.classLoader;
this.loadDefaults = other.loadDefaults;
setQuietMode(other.getQuietMode());
} }
/** /**
@ -1025,7 +1025,6 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
getProps().setProperty(name, value); getProps().setProperty(name, value);
String newSource = (source == null ? "programmatically" : source); String newSource = (source == null ? "programmatically" : source);
synchronized (this) {
if (!isDeprecated(name)) { if (!isDeprecated(name)) {
updatingResource.put(name, new String[] {newSource}); updatingResource.put(name, new String[] {newSource});
String[] altNames = getAlternativeNames(name); String[] altNames = getAlternativeNames(name);
@ -1049,7 +1048,6 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
} }
} }
} }
}
private void warnOnceIfDeprecated(DeprecationContext deprecations, String name) { private void warnOnceIfDeprecated(DeprecationContext deprecations, String name) {
DeprecatedKeyInfo keyInfo = deprecations.getDeprecatedKeyMap().get(name); DeprecatedKeyInfo keyInfo = deprecations.getDeprecatedKeyMap().get(name);
@ -2279,7 +2277,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
* *
* @return final parameter set. * @return final parameter set.
*/ */
public synchronized Set<String> getFinalParameters() { public Set<String> getFinalParameters() {
return new HashSet<String>(finalParameters); return new HashSet<String>(finalParameters);
} }
@ -2542,20 +2540,16 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
if (value != null) { if (value != null) {
if (!finalParameters.contains(attr)) { if (!finalParameters.contains(attr)) {
properties.setProperty(attr, value); properties.setProperty(attr, value);
synchronized(this) {
updatingResource.put(attr, source); updatingResource.put(attr, source);
}
} else if (!value.equals(properties.getProperty(attr))) { } else if (!value.equals(properties.getProperty(attr))) {
LOG.warn(name+":an attempt to override final parameter: "+attr LOG.warn(name+":an attempt to override final parameter: "+attr
+"; Ignoring."); +"; Ignoring.");
} }
} }
if (finalParameter) { if (finalParameter) {
synchronized(this) {
finalParameters.add(attr); finalParameters.add(attr);
} }
} }
}
/** /**
* Write out the non-default properties in this configuration to the given * Write out the non-default properties in this configuration to the given
@ -2747,7 +2741,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
} }
@Override @Override
public synchronized void readFields(DataInput in) throws IOException { public void readFields(DataInput in) throws IOException {
clear(); clear();
int size = WritableUtils.readVInt(in); int size = WritableUtils.readVInt(in);
for(int i=0; i < size; ++i) { for(int i=0; i < size; ++i) {
@ -2759,8 +2753,9 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
} }
} }
//@Override
@Override @Override
public synchronized void write(DataOutput out) throws IOException { public void write(DataOutput out) throws IOException {
Properties props = getProps(); Properties props = getProps();
WritableUtils.writeVInt(out, props.size()); WritableUtils.writeVInt(out, props.size());
for(Map.Entry<Object, Object> item: props.entrySet()) { for(Map.Entry<Object, Object> item: props.entrySet()) {