avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1060089 - in /avro/trunk: CHANGES.txt lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java
Date Mon, 17 Jan 2011 20:57:54 GMT
Author: cutting
Date: Mon Jan 17 20:57:54 2011
New Revision: 1060089

URL: http://svn.apache.org/viewvc?rev=1060089&view=rev
Log:
AVRO-688. Java: Only require that one-way'ness of messages match over stateful connections.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java
    avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1060089&r1=1060088&r2=1060089&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Mon Jan 17 20:57:54 2011
@@ -159,6 +159,10 @@ Avro 1.5.0 (unreleased)
     AVRO-663. Java: avro-tools.jar does not meet maven2 layout standard.
     (scottcarey)
 
+    AVRO-688. Java: Only require that one-way'ness of messages match
+    over stateful connections, permitting interoperability with
+    Python and Ruby, which drop the one-way message attribute. (cutting)
+
 Avro 1.4.1 (13 October 2010)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java?rev=1060089&r1=1060088&r2=1060089&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Requestor.java Mon Jan 17 20:57:54
2011
@@ -130,7 +130,8 @@ public abstract class Requestor {
     Message rm = remote.getMessages().get(messageName);
     if (rm == null)
       throw new AvroRuntimeException("Not a remote message: "+messageName);
-    if (m.isOneWay() != rm.isOneWay())
+
+    if ((m.isOneWay() != rm.isOneWay()) && t.isConnected())
       throw new AvroRuntimeException("Not both one-way messages: "+messageName);
 
     if (m.isOneWay() && t.isConnected()) return null; // one-way w/ handshake

Modified: avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java?rev=1060089&r1=1060088&r2=1060089&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java (original)
+++ avro/trunk/lang/java/ipc/src/main/java/org/apache/avro/ipc/Responder.java Mon Jan 17 20:57:54
2011
@@ -136,7 +136,7 @@ public abstract class Responder {
       if (m == null)
         throw new AvroRuntimeException("No message named "+messageName
                                        +" in "+getLocal());
-      if (m.isOneWay() != rm.isOneWay())
+      if ((m.isOneWay() != rm.isOneWay()) && wasConnected)
         throw new AvroRuntimeException("Not both one-way: "+messageName);
 
       Object response = null;

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java?rev=1060089&r1=1060088&r2=1060089&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestProtocolHttp.java Mon Jan 17
20:57:54 2011
@@ -17,11 +17,15 @@
  */
 package org.apache.avro;
 
+import org.apache.avro.Schema;
+import org.apache.avro.Schema.Field;
 import org.apache.avro.ipc.Server;
 import org.apache.avro.ipc.Transceiver;
 import org.apache.avro.ipc.Responder;
 import org.apache.avro.ipc.HttpServer;
 import org.apache.avro.ipc.HttpTransceiver;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericRequestor;
 import org.apache.avro.specific.SpecificRequestor;
 import org.apache.avro.test.Simple;
 
@@ -31,6 +35,7 @@ import java.net.URL;
 import java.net.ServerSocket;
 import java.net.SocketTimeoutException;
 import java.lang.reflect.UndeclaredThrowableException;
+import java.util.ArrayList;
 
 public class TestProtocolHttp extends TestProtocolSpecific {
 
@@ -64,4 +69,20 @@ public class TestProtocolHttp extends Te
     }
   }
 
+  /** Test that Responder ignores one-way with stateless transport. */
+  @Test public void testStatelessOneway() throws Exception {
+    // a version of the Simple protocol that doesn't declare "ack" one-way
+    Protocol protocol = new Protocol("Simple", "org.apache.avro.test");
+    Protocol.Message message =
+      protocol.createMessage("ack", null,
+                             Schema.createRecord(new ArrayList<Field>()),
+                             Schema.create(Schema.Type.NULL),
+                             Schema.createUnion(new ArrayList<Schema>()));
+    protocol.getMessages().put("ack", message);
+
+    // call a server over a stateless protocol that has a one-way "ack"
+    new GenericRequestor(protocol, createTransceiver())
+      .request("ack", new GenericData.Record(message.getRequest()));
+  }
+
 }



Mime
View raw message