You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2007/09/24 21:57:15 UTC

svn commit: r578936 - in /incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient: Client.java interop/BasicInteropTest.java

Author: rhs
Date: Mon Sep 24 12:57:14 2007
New Revision: 578936

URL: http://svn.apache.org/viewvc?rev=578936&view=rev
Log:
Client.java: workaround for NPE + close underling connection. BasicInteropTest.java: added a connection close and a flush so that the message will definitely be received prior to the JVM exiting.

Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java?rev=578936&r1=578935&r2=578936&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/Client.java Mon Sep 24 12:57:14 2007
@@ -51,11 +51,16 @@
 
             @Override public void connectionClose(Channel context, ConnectionClose connectionClose)
             {
-                _exceptionListner.onException(
-                        new QpidException("Server closed the connection: Reason " +
-                                           connectionClose.getReplyText(),
-                                           ErrorCode.get(connectionClose.getReplyCode()),
-                                           null));
+                // XXX: replaced reference to _exceptionListner with
+                // throw new RuntimeException because
+                // _exceptionListner may be null. In general this
+                // needs to be reworked because not every connection
+                // close is an exception!
+                throw new RuntimeException
+                    (new QpidException("Server closed the connection: Reason " +
+                                       connectionClose.getReplyText(),
+                                       ErrorCode.get(connectionClose.getReplyCode()),
+                                       null));
             }
         };
 
@@ -102,7 +107,7 @@
     {
         Channel ch = _conn.getChannel(0);
         ch.connectionClose(0, "client is closing", 0, 0);
-        //need to close the connection underneath as well
+        _conn.close();
     }
 
     public Session createSession(long expiryInSeconds)

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java?rev=578936&r1=578935&r2=578936&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/nclient/interop/BasicInteropTest.java Mon Sep 24 12:57:14 2007
@@ -25,6 +25,11 @@
         this.host = host;
     }
 
+    public void close() throws QpidException
+    {
+        conn.close();
+    }
+
     public void testCreateConnection(){
         System.out.println("------- Creating connection--------");
         conn = Client.createConnection();
@@ -46,7 +51,7 @@
 
     public void testExchange(){
         System.out.println("------- Creating an exchange --------");
-        session.exchangeDeclare("test", "amq.direct", "", null);
+        session.exchangeDeclare("test", "direct", "", null);
         session.sync();
         System.out.println("------- Exchange created --------");
     }
@@ -73,7 +78,8 @@
         System.out.println("------- Message sent --------");
     }
 
-    public void testSubscribe(){
+    public void testSubscribe()
+    {
         System.out.println("------- Sending a subscribe --------");
         session.messageSubscribe("testQueue", "myDest",
                                  Session.TRANSFER_CONFIRM_MODE_REQUIRED,
@@ -97,6 +103,13 @@
         session.messageFlowMode("myDest", Session.MESSAGE_FLOW_MODE_WINDOW);
         System.out.println("------- Setting Credit --------");
         session.messageFlow("myDest", Session.MESSAGE_FLOW_UNIT_MESSAGE, 1);
+        session.messageFlow("myDest", Session.MESSAGE_FLOW_UNIT_BYTE, -1);
+    }
+
+    public void testMessageFlush()
+    {
+        session.messageFlush("myDest");
+        session.sync();
     }
 
     public void onException(QpidException e)
@@ -107,7 +120,7 @@
         System.out.println("------- /Broker Notified an error --------");
     }
 
-    public static void main(String[] args)
+    public static void main(String[] args) throws QpidException
     {
         String host = "0.0.0.0";
         if (args.length>0)
@@ -122,5 +135,7 @@
         t.testQueue();
         t.testSubscribe();
         t.testSendMessage();
+        t.testMessageFlush();
+        t.close();
     }
 }