avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r951216 - in /avro/branches/branch-1.3: ./ CHANGES.txt lang/java/src/java/org/apache/avro/reflect/ReflectData.java lang/java/src/test/java/org/apache/avro/TestReflect.java
Date Thu, 03 Jun 2010 23:59:02 GMT
Author: cutting
Date: Thu Jun  3 23:59:01 2010
New Revision: 951216

URL: http://svn.apache.org/viewvc?rev=951216&view=rev
Log:
Merged r944035 and r944049 from trunk to 1.3 branch.  Fixes: AVRO-499.

Modified:
    avro/branches/branch-1.3/   (props changed)
    avro/branches/branch-1.3/CHANGES.txt
    avro/branches/branch-1.3/lang/java/src/java/org/apache/avro/reflect/ReflectData.java
    avro/branches/branch-1.3/lang/java/src/test/java/org/apache/avro/TestReflect.java

Propchange: avro/branches/branch-1.3/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun  3 23:59:01 2010
@@ -1 +1,2 @@
+/avro/trunk:944035,944049
 /hadoop/avro/trunk:935526,938347

Modified: avro/branches/branch-1.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.3/CHANGES.txt?rev=951216&r1=951215&r2=951216&view=diff
==============================================================================
--- avro/branches/branch-1.3/CHANGES.txt (original)
+++ avro/branches/branch-1.3/CHANGES.txt Thu Jun  3 23:59:01 2010
@@ -22,6 +22,9 @@ Avro 1.3.3 (Unreleased)
 
     AVRO-524. DataFileWriter.appendTo leads to intermittent IOException during write() (thiru)
 
+    AVRO-499. Java: Fix protocol reflection to reject interfaces with
+    multiple methods of the same name.  (cutting)
+
 Avro 1.3.2 (31 March 2010)
 
   IMPROVEMENTS

Modified: avro/branches/branch-1.3/lang/java/src/java/org/apache/avro/reflect/ReflectData.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.3/lang/java/src/java/org/apache/avro/reflect/ReflectData.java?rev=951216&r1=951215&r2=951216&view=diff
==============================================================================
--- avro/branches/branch-1.3/lang/java/src/java/org/apache/avro/reflect/ReflectData.java (original)
+++ avro/branches/branch-1.3/lang/java/src/java/org/apache/avro/reflect/ReflectData.java Thu
Jun  3 23:59:01 2010
@@ -355,10 +355,14 @@ public class ReflectData extends Specifi
     Protocol protocol =
       new Protocol(iface.getSimpleName(), iface.getPackage().getName()); 
     Map<String,Schema> names = new LinkedHashMap<String,Schema>();
+    Map<String,Message> messages = protocol.getMessages();
     for (Method method : iface.getMethods())
-      if ((method.getModifiers() & Modifier.STATIC) == 0)
-        protocol.getMessages().put(method.getName(),
-                                   getMessage(method, protocol, names));
+      if ((method.getModifiers() & Modifier.STATIC) == 0) {
+        String name = method.getName();
+        if (messages.containsKey(name))
+          throw new AvroTypeException("Two methods with same name: "+name);
+        messages.put(name, getMessage(method, protocol, names));
+      }
 
     // reverse types, since they were defined in reference order
     List<Schema> types = new ArrayList<Schema>();

Modified: avro/branches/branch-1.3/lang/java/src/test/java/org/apache/avro/TestReflect.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.3/lang/java/src/test/java/org/apache/avro/TestReflect.java?rev=951216&r1=951215&r2=951216&view=diff
==============================================================================
--- avro/branches/branch-1.3/lang/java/src/test/java/org/apache/avro/TestReflect.java (original)
+++ avro/branches/branch-1.3/lang/java/src/test/java/org/apache/avro/TestReflect.java Thu
Jun  3 23:59:01 2010
@@ -501,4 +501,15 @@ public class TestReflect {
     assert(reparsed.getTypes().contains(data.getSchema(X.class)));
   }
 
+  public static interface P3 {
+    void m1();
+    void m1(int x);
+  }
+
+  @Test(expected=AvroTypeException.class)
+  public void testOverloadedMethod() { 
+    ReflectData.get().getProtocol(P3.class);
+  }
+
+
 }



Mime
View raw message