ArchiveOrangemail archive

commits.avro.apache.org


(List home) (Recent threads) (2 other Apache Avro lists)

Subscription Options

  • RSS or Atom: Read-only subscription using a browser or aggregator. This is the recommended way if you don't need to send messages to the list. You can learn more about feed syndication and clients here.
  • Conventional: All messages are delivered to your mail address, and you can reply. To subscribe, send an email to the list's subscribe address with "subscribe" in the subject line.
  • Low traffic list: less than 3 messages per day
  • This list contains about 980 messages, beginning May 2010
  • 0 messages added yesterday
Report the Spam
This button sends a spam report to the moderator. Please use it sparingly. For other removal requests, read this.
Are you sure? yes no

svn commit: r944035 - in /avro/trunk/lang/java/src: java/org/apache/avro/reflect/ReflectData.java test/java/org/apache/avro/TestReflect.java

Ad
cutting1273789624Thu, 13 May 2010 22:27:04 +0000 (UTC)
Author: cutting
Date: Thu May 13 22:26:42 2010
New Revision: 944035

URL: http://svn.apache.org/viewvc?rev=944035&v...
Log:
AVRO-499. Java: Fix protocol reflection to reject interfaces with multiple methods of the same name.

Modified:
    avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectData.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestReflect.java

Modified: avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/...
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectData.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectData.java Thu May 13 22:26:42 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/trunk/lang/java/src/test/java/org/apache/avro/TestReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/...
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestReflect.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestReflect.java Thu May 13 22:26:42 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);
+  }
+
+
 }
Home | About | Privacy