From 7a91ea32e1085e075de232a3d5060f54cdcb75de Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Thu, 6 Nov 2014 18:27:59 -0800 Subject: [PATCH] Revert "HADOOP-11274. ConcurrentModificationException in Configuration Copy Constructor. Contributed by Junping Du." This reverts commit 16b34824673f5a50d464727b8fad98470e5e984a. --- .../hadoop-common/CHANGES.txt | 3 - .../org/apache/hadoop/conf/Configuration.java | 81 +++++++++---------- 2 files changed, 38 insertions(+), 46 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 5eb4e7fd6e0..8e21669a96c 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -381,9 +381,6 @@ Release 2.6.0 - UNRELEASED HADOOP-11253. Hadoop streaming test TestStreamXmlMultipleRecords fails on 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 HADOOP-10734. Implement high-performance secure random number sources. diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java index 587f9c517c4..12768656fe2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java @@ -690,26 +690,26 @@ public Configuration(boolean loadDefaults) { */ @SuppressWarnings("unchecked") public Configuration(Configuration other) { - synchronized(other) { - this.resources = (ArrayList) other.resources.clone(); - if (other.properties != null) { - this.properties = (Properties)other.properties.clone(); - } + this.resources = (ArrayList) other.resources.clone(); + synchronized(other) { + if (other.properties != null) { + this.properties = (Properties)other.properties.clone(); + } - if (other.overlay!=null) { - this.overlay = (Properties)other.overlay.clone(); - } + if (other.overlay!=null) { + this.overlay = (Properties)other.overlay.clone(); + } - this.updatingResource = new HashMap(other.updatingResource); - this.finalParameters = new HashSet(other.finalParameters); - - this.classLoader = other.classLoader; - this.loadDefaults = other.loadDefaults; - setQuietMode(other.getQuietMode()); - } + this.updatingResource = new HashMap(other.updatingResource); + this.finalParameters = new HashSet(other.finalParameters); + } + synchronized(Configuration.class) { REGISTRY.put(this, null); } + this.classLoader = other.classLoader; + this.loadDefaults = other.loadDefaults; + setQuietMode(other.getQuietMode()); } /** @@ -1019,28 +1019,26 @@ public void set(String name, String value, String source) { getProps().setProperty(name, value); String newSource = (source == null ? "programatically" : source); - synchronized (this) { - if (!isDeprecated(name)) { - updatingResource.put(name, new String[] {newSource}); - String[] altNames = getAlternativeNames(name); - if(altNames != null) { - for(String n: altNames) { - if(!n.equals(name)) { - getOverlay().setProperty(n, value); - getProps().setProperty(n, value); - updatingResource.put(n, new String[] {newSource}); - } + if (!isDeprecated(name)) { + updatingResource.put(name, new String[] {newSource}); + String[] altNames = getAlternativeNames(name); + if(altNames != null) { + for(String n: altNames) { + if(!n.equals(name)) { + getOverlay().setProperty(n, value); + getProps().setProperty(n, value); + updatingResource.put(n, new String[] {newSource}); } } } - else { - String[] names = handleDeprecation(deprecationContext.get(), name); - String altSource = "because " + name + " is deprecated"; - for(String n : names) { - getOverlay().setProperty(n, value); - getProps().setProperty(n, value); - updatingResource.put(n, new String[] {altSource}); - } + } + else { + String[] names = handleDeprecation(deprecationContext.get(), name); + String altSource = "because " + name + " is deprecated"; + for(String n : names) { + getOverlay().setProperty(n, value); + getProps().setProperty(n, value); + updatingResource.put(n, new String[] {altSource}); } } } @@ -2271,7 +2269,7 @@ public Reader getConfResourceAsReader(String name) { * * @return final parameter set. */ - public synchronized Set getFinalParameters() { + public Set getFinalParameters() { return new HashSet(finalParameters); } @@ -2534,18 +2532,14 @@ private void loadProperty(Properties properties, String name, String attr, if (value != null) { if (!finalParameters.contains(attr)) { properties.setProperty(attr, value); - synchronized(this) { - updatingResource.put(attr, source); - } + updatingResource.put(attr, source); } else if (!value.equals(properties.getProperty(attr))) { LOG.warn(name+":an attempt to override final parameter: "+attr +"; Ignoring."); } } if (finalParameter) { - synchronized(this) { - finalParameters.add(attr); - } + finalParameters.add(attr); } } @@ -2739,7 +2733,7 @@ public static void main(String[] args) throws Exception { } @Override - public synchronized void readFields(DataInput in) throws IOException { + public void readFields(DataInput in) throws IOException { clear(); int size = WritableUtils.readVInt(in); for(int i=0; i < size; ++i) { @@ -2751,8 +2745,9 @@ public synchronized void readFields(DataInput in) throws IOException { } } + //@Override @Override - public synchronized void write(DataOutput out) throws IOException { + public void write(DataOutput out) throws IOException { Properties props = getProps(); WritableUtils.writeVInt(out, props.size()); for(Map.Entry item: props.entrySet()) {