Return-Path: Delivered-To: apmail-avro-commits-archive@www.apache.org Received: (qmail 30042 invoked from network); 17 Jan 2011 20:58:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Jan 2011 20:58:22 -0000 Received: (qmail 3778 invoked by uid 500); 17 Jan 2011 20:58:22 -0000 Delivered-To: apmail-avro-commits-archive@avro.apache.org Received: (qmail 3741 invoked by uid 500); 17 Jan 2011 20:58:21 -0000 Mailing-List: contact commits-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list commits@avro.apache.org Received: (qmail 3732 invoked by uid 99); 17 Jan 2011 20:58:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jan 2011 20:58:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jan 2011 20:58:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BF38D23889D5; Mon, 17 Jan 2011 20:57:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@avro.apache.org From: cutting@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110117205754.BF38D23889D5@eris.apache.org> 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()), + Schema.create(Schema.Type.NULL), + Schema.createUnion(new ArrayList())); + 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())); + } + }