avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1442612 - in /avro/trunk: ./ lang/java/avro/src/main/java/org/apache/avro/generic/ lang/java/avro/src/main/java/org/apache/avro/reflect/ lang/java/avro/src/main/java/org/apache/avro/specific/
Date Tue, 05 Feb 2013 14:47:17 GMT
Author: cutting
Date: Tue Feb  5 14:47:17 2013
New Revision: 1442612

URL: http://svn.apache.org/viewvc?rev=1442612&view=rev
Log:
AVRO-1240. Java: Fix SpecificDatumReader(Class) constructor to use correct ClassLoader.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumReader.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumReader.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1442612&r1=1442611&r2=1442612&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Feb  5 14:47:17 2013
@@ -43,6 +43,9 @@ Trunk (not yet released)
     AVRO-1228. Java: Fix Trevni to use default values for missing Avro fields.
     (cutting)
 
+    AVRO-1240. Java: Fix SpecificDatumReader(Class) constructor to use
+    correct ClassLoader. (cutting)
+
 Avro 1.7.3 (6 December 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java?rev=1442612&r1=1442611&r2=1442612&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java
Tue Feb  5 14:47:17 2013
@@ -57,8 +57,12 @@ public class GenericDatumReader<D> imple
   }
 
   protected GenericDatumReader(Schema writer, Schema reader, GenericData data) {
+    this(data);
     this.actual = writer;
     this.expected = reader;
+  }
+
+  protected GenericDatumReader(GenericData data) {
     this.data = data;
     this.creator = Thread.currentThread();
   }

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumReader.java?rev=1442612&r1=1442611&r2=1442612&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumReader.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumReader.java
Tue Feb  5 14:47:17 2013
@@ -38,8 +38,10 @@ public class ReflectDatumReader<T> exten
     this(null, null, ReflectData.get());
   }
 
+  /** Construct for reading instances of a class. */
   public ReflectDatumReader(Class<T> c) {
-    this(ReflectData.get().getSchema(c));
+    this(new ReflectData(c.getClassLoader()));
+    setSchema(getSpecificData().getSchema(c));
   }
 
   /** Construct where the writer's and reader's schemas are the same. */
@@ -57,6 +59,11 @@ public class ReflectDatumReader<T> exten
     super(writer, reader, data);
   }
 
+  /** Construct given a {@link ReflectData}. */
+  public ReflectDatumReader(ReflectData data) {
+    super(data);
+  }
+
   @Override
   @SuppressWarnings(value="unchecked")
   protected Object newArray(Object old, int size, Schema schema) {

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumReader.java?rev=1442612&r1=1442611&r2=1442612&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumReader.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificDatumReader.java
Tue Feb  5 14:47:17 2013
@@ -26,8 +26,10 @@ public class SpecificDatumReader<T> exte
     this(null, null, SpecificData.get());
   }
 
+  /** Construct for reading instances of a class. */
   public SpecificDatumReader(Class<T> c) {
-    this(SpecificData.get().getSchema(c));
+    this(new SpecificData(c.getClassLoader()));
+    setSchema(getSpecificData().getSchema(c));
   }
 
   /** Construct where the writer's and reader's schemas are the same. */
@@ -47,6 +49,11 @@ public class SpecificDatumReader<T> exte
     super(writer, reader, data);
   }
 
+  /** Construct given a {@link SpecificData}. */
+  public SpecificDatumReader(SpecificData data) {
+    super(data);
+  }
+
   /** Return the contained {@link SpecificData}. */
   public SpecificData getSpecificData() { return (SpecificData)getData(); }
 



Mime
View raw message