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 ae...@apache.org on 2016/04/14 08:15:25 UTC
[18/40] hadoop git commit: HADOOP-12406. Fixed
AbstractMapWritable.readFields to use the thread's ClassLoader to load class
instead of System ClassLoader. Contributed by Nadeem Douba.
HADOOP-12406. Fixed AbstractMapWritable.readFields to use the thread's ClassLoader to load class instead of System ClassLoader. Contributed by Nadeem Douba.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/069c6c62
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/069c6c62
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/069c6c62
Branch: refs/heads/HDFS-7240
Commit: 069c6c62def4a0f94382e9f149581d8e22f6d31c
Parents: 2a5da97
Author: Vinod Kumar Vavilapalli <vi...@apache.org>
Authored: Mon Apr 11 12:00:51 2016 -0700
Committer: Vinod Kumar Vavilapalli <vi...@apache.org>
Committed: Mon Apr 11 12:02:06 2016 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/io/AbstractMapWritable.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/069c6c62/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
index 7dd9e69..44e0bdc 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/AbstractMapWritable.java
@@ -181,20 +181,22 @@ public abstract class AbstractMapWritable implements Writable, Configurable {
public void readFields(DataInput in) throws IOException {
// Get the number of "unknown" classes
-
newClasses = in.readByte();
-
+
+ // Use the classloader of the current thread to load classes instead of the
+ // system-classloader so as to support both client-only and inside-a-MR-job
+ // use-cases. The context-loader by default eventually falls back to the
+ // system one, so there should be no cases where changing this is an issue.
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
// Then read in the class names and add them to our tables
-
for (int i = 0; i < newClasses; i++) {
byte id = in.readByte();
String className = in.readUTF();
try {
- addToMap(Class.forName(className), id);
-
+ addToMap(classLoader.loadClass(className), id);
} catch (ClassNotFoundException e) {
- throw new IOException("can't find class: " + className + " because "+
- e.getMessage());
+ throw new IOException(e);
}
}
}