avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r825217 - in /hadoop/avro/trunk: CHANGES.txt src/java/org/apache/avro/reflect/ReflectData.java src/test/java/org/apache/avro/TestReflect.java
Date Wed, 14 Oct 2009 18:50:49 GMT
Author: cutting
Date: Wed Oct 14 18:50:49 2009
New Revision: 825217

URL: http://svn.apache.org/viewvc?rev=825217&view=rev
Log:
AVRO-141.  Fix a NullPointerException in ReflectData#isRecord().  Contributed by Isabel Drost.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java
    hadoop/avro/trunk/src/test/java/org/apache/avro/TestReflect.java

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=825217&r1=825216&r2=825217&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Wed Oct 14 18:50:49 2009
@@ -1,5 +1,20 @@
 Avro Change Log
 
+Trunk (unreleased changes)
+
+  INCOMPATIBLE CHANGES
+
+  NEW FEATURES
+
+  IMPROVEMENTS
+
+  OPTIMIZATIONS
+
+  BUG FIXES
+ 
+    AVRO-141.  Fix a NullPointerException in ReflectData#isRecord().
+    (Isabel Drost via cutting)
+
 Avro 1.2.0 (14 October 2009)
 
   INCOMPATIBLE CHANGES

Modified: hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java?rev=825217&r1=825216&r2=825217&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/reflect/ReflectData.java Wed Oct 14 18:50:49
2009
@@ -76,6 +76,7 @@
 
   @Override
   protected boolean isRecord(Object datum) {
+    if (datum == null) return false;
     return getSchema(datum.getClass()).getType() == Type.RECORD;
   }
 

Modified: hadoop/avro/trunk/src/test/java/org/apache/avro/TestReflect.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/java/org/apache/avro/TestReflect.java?rev=825217&r1=825216&r2=825217&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/java/org/apache/avro/TestReflect.java (original)
+++ hadoop/avro/trunk/src/test/java/org/apache/avro/TestReflect.java Wed Oct 14 18:50:49 2009
@@ -121,23 +121,32 @@
     
     public static class AnotherSampleRecord {
       private Integer a = null;
-      
+      private SampleRecord s = null;
+
       public AnotherSampleRecord() {
       }
-      
+
       AnotherSampleRecord(Integer a) {
         this.a = a;
+        this.s = new SampleRecord();
       }
 
       public int hashCode() {
-        return (a != null ? a.hashCode() : 0);
+        int hash = (a != null ? a.hashCode() : 0);
+        hash += (s != null ? s.hashCode() : 0);
+        return hash;
       }
 
       public boolean equals(Object other) {
         if (other instanceof AnotherSampleRecord) {
-          return this.a == ((AnotherSampleRecord)other).a;
+          AnotherSampleRecord o = (AnotherSampleRecord) other;
+          boolean equals = this.a == o.a;
+          if (this.s == null && o.s != null)
+            equals = false;
+          if (this.s != null && this.s.equals(o.s))
+            equals = true;
         }
-        return false;
+        return true;
       }
     }
   }



Mime
View raw message