You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2014/11/07 01:59:57 UTC
hadoop git commit: HADOOP-11274. ConcurrentModificationException in
Configuration Copy Constructor. Contributed by Junping Du.
Repository: hadoop
Updated Branches:
refs/heads/trunk 75b820cca -> 16b348246
HADOOP-11274. ConcurrentModificationException in Configuration Copy Constructor. Contributed by Junping Du.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/16b34824
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/16b34824
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/16b34824
Branch: refs/heads/trunk
Commit: 16b34824673f5a50d464727b8fad98470e5e984a
Parents: 75b820c
Author: Jing Zhao <ji...@apache.org>
Authored: Thu Nov 6 16:07:50 2014 -0800
Committer: Jing Zhao <ji...@apache.org>
Committed: Thu Nov 6 16:07:50 2014 -0800
----------------------------------------------------------------------
hadoop-common-project/hadoop-common/CHANGES.txt | 3 +
.../org/apache/hadoop/conf/Configuration.java | 85 +++++++++++---------
2 files changed, 48 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/16b34824/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index 8587f12..679b5bb 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -910,6 +910,9 @@ 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.
http://git-wip-us.apache.org/repos/asf/hadoop/blob/16b34824/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/Configuration.java
----------------------------------------------------------------------
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 a3fae19..16d5499 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 class Configuration implements Iterable<Map.Entry<String,String>>,
*/
@SuppressWarnings("unchecked")
public Configuration(Configuration other) {
- this.resources = (ArrayList<Resource>) 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();
- }
-
- this.updatingResource = new HashMap<String, String[]>(other.updatingResource);
- this.finalParameters = new HashSet<String>(other.finalParameters);
- }
-
+ synchronized(other) {
+ this.resources = (ArrayList<Resource>) other.resources.clone();
+ if (other.properties != null) {
+ this.properties = (Properties)other.properties.clone();
+ }
+
+ if (other.overlay!=null) {
+ this.overlay = (Properties)other.overlay.clone();
+ }
+
+ this.updatingResource = new HashMap<String, String[]>(other.updatingResource);
+ this.finalParameters = new HashSet<String>(other.finalParameters);
+
+ this.classLoader = other.classLoader;
+ this.loadDefaults = other.loadDefaults;
+ setQuietMode(other.getQuietMode());
+ }
synchronized(Configuration.class) {
REGISTRY.put(this, null);
}
- this.classLoader = other.classLoader;
- this.loadDefaults = other.loadDefaults;
- setQuietMode(other.getQuietMode());
}
/**
@@ -1025,26 +1025,28 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
getProps().setProperty(name, value);
String newSource = (source == null ? "programmatically" : source);
- 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});
+ 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});
+ }
}
}
}
- }
- 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});
+ }
}
}
}
@@ -2277,7 +2279,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
*
* @return final parameter set.
*/
- public Set<String> getFinalParameters() {
+ public synchronized Set<String> getFinalParameters() {
return new HashSet<String>(finalParameters);
}
@@ -2540,14 +2542,18 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
if (value != null) {
if (!finalParameters.contains(attr)) {
properties.setProperty(attr, value);
- updatingResource.put(attr, source);
+ synchronized(this) {
+ updatingResource.put(attr, source);
+ }
} else if (!value.equals(properties.getProperty(attr))) {
LOG.warn(name+":an attempt to override final parameter: "+attr
+"; Ignoring.");
}
}
if (finalParameter) {
- finalParameters.add(attr);
+ synchronized(this) {
+ finalParameters.add(attr);
+ }
}
}
@@ -2741,7 +2747,7 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
}
@Override
- public void readFields(DataInput in) throws IOException {
+ public synchronized void readFields(DataInput in) throws IOException {
clear();
int size = WritableUtils.readVInt(in);
for(int i=0; i < size; ++i) {
@@ -2753,9 +2759,8 @@ public class Configuration implements Iterable<Map.Entry<String,String>>,
}
}
- //@Override
@Override
- public void write(DataOutput out) throws IOException {
+ public synchronized void write(DataOutput out) throws IOException {
Properties props = getProps();
WritableUtils.writeVInt(out, props.size());
for(Map.Entry<Object, Object> item: props.entrySet()) {