hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r440866 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/io/ObjectWritable.java src/java/org/apache/hadoop/io/WritableFactories.java
Date Wed, 06 Sep 2006 20:56:51 GMT
Author: cutting
Date: Wed Sep  6 13:56:51 2006
New Revision: 440866

URL: http://svn.apache.org/viewvc?view=rev&rev=440866
Log:
HADOOP-507.  Fix an IllegalAccessException in DFS.  Contributed by Owen.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableFactories.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=440866&r1=440865&r2=440866
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Sep  6 13:56:51 2006
@@ -126,6 +126,9 @@
 31. HADOOP-408.  Adjust some timeouts and remove some others so that
     unit tests run faster.  (cutting)
 
+32. HADOOP-507.  Fix an IllegalAccessException in DFS.
+    (omalley via cutting)
+
 
 Release 0.5.0 - 2006-08-04
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java?view=diff&rev=440866&r1=440865&r2=440866
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/ObjectWritable.java Wed Sep  6 13:56:51
2006
@@ -223,10 +223,7 @@
         throw new RuntimeException("readObject can't find class", e);
       }
       
-      Writable writable = WritableFactories.newInstance(instanceClass);
-      if(writable instanceof Configurable) {
-        ((Configurable) writable).setConf(conf);
-      }
+      Writable writable = WritableFactories.newInstance(instanceClass, conf);
       writable.readFields(in);
       instance = writable;
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableFactories.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableFactories.java?view=diff&rev=440866&r1=440865&r2=440866
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableFactories.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/io/WritableFactories.java Wed Sep  6 13:56:51
2006
@@ -16,6 +16,8 @@
 
 package org.apache.hadoop.io;
 
+import org.apache.hadoop.conf.*;
+import org.apache.hadoop.util.ReflectionUtils;
 import java.util.HashMap;
 
 /** Factories for non-public writables.  Defining a factory permits {@link
@@ -36,19 +38,22 @@
   }
 
   /** Create a new instance of a class with a defined factory. */
-  public static Writable newInstance(Class c) {
+  public static Writable newInstance(Class c, Configuration conf) {
     WritableFactory factory = WritableFactories.getFactory(c);
     if (factory != null) {
-      return factory.newInstance();
-    } else {
-      try {
-        return (Writable)c.newInstance();
-      } catch (InstantiationException e) {
-        throw new RuntimeException(e);
-      } catch (IllegalAccessException e) {
-        throw new RuntimeException(e);
+      Writable result = factory.newInstance();
+      if (result instanceof Configurable) {
+        ((Configurable) result).setConf(conf);
       }
+      return result;
+    } else {
+      return (Writable)ReflectionUtils.newInstance(c, conf);
     }
+  }
+  
+  /** Create a new instance of a class with a defined factory. */
+  public static Writable newInstance(Class c) {
+    return newInstance(c, null);
   }
 
 }



Mime
View raw message