[prev in list] [next in list] [prev in thread] [next in thread]
List: avro-commits
Subject: svn commit: r944035 - in /avro/trunk/lang/java/src: java/org/apache/avro/reflect/ReflectData.java
From: cutting () apache ! org
Date: 2010-05-13 22:26:43
Message-ID: 20100513222643.4716123889E1 () eris ! apache ! org
[Download RAW message or body]
Author: cutting
Date: Thu May 13 22:26:42 2010
New Revision: 944035
URL: http://svn.apache.org/viewvc?rev=944035&view=rev
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/java/src/java/org/apache/avro/reflect/ReflectData.java?rev=944035&r1=944034&r2=944035&view=diff
==============================================================================
--- 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/java/src/test/java/org/apache/avro/TestReflect.java?rev=944035&r1=944034&r2=944035&view=diff
==============================================================================
--- 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);
+ }
+
+
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic