Repository: qpid-jms
Updated Branches:
  refs/heads/master 612539463 -> 199cc7351


QPIDJMS-45: update peer to allow suppressing read exception that might occur on 
some platforms when the client severs the connection as expected in one of the 
tests


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/199cc735
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/199cc735
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/199cc735

Branch: refs/heads/master
Commit: 199cc73519656485ed6e9eb432af436a09e192ec
Parents: 6125394
Author: Robert Gemmell <[email protected]>
Authored: Tue May 12 11:28:30 2015 +0100
Committer: Robert Gemmell <[email protected]>
Committed: Tue May 12 11:28:30 2015 +0100

----------------------------------------------------------------------
 .../jms/integration/IdleTimeoutIntegrationTest.java |  1 +
 .../apache/qpid/jms/test/testpeer/TestAmqpPeer.java |  5 +++++
 .../qpid/jms/test/testpeer/TestAmqpPeerRunner.java  | 16 +++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/199cc735/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IdleTimeoutIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IdleTimeoutIntegrationTest.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IdleTimeoutIntegrationTest.java
index 7ebd8fd..6e7db22 100644
--- 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IdleTimeoutIntegrationTest.java
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IdleTimeoutIntegrationTest.java
@@ -181,6 +181,7 @@ public class IdleTimeoutIntegrationTest extends 
QpidJmsTestCase {
             // The peer is still connected, so it will get the close frame 
with error
             testPeer.expectClose(Matchers.notNullValue());
             assertNull(testPeer.getThrowable());
+            testPeer.setSuppressReadExceptionOnClose(true);
 
             boolean failed = Wait.waitFor(new Wait.Condition() {
                 @Override

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/199cc735/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index c12d575..3fdf13e 100644
--- 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -172,6 +172,11 @@ public class TestAmqpPeer implements AutoCloseable
         return _driverRunnable.getException();
     }
 
+    public void setSuppressReadExceptionOnClose(boolean suppress)
+    {
+        _driverRunnable.setSuppressReadExceptionOnClose(suppress);
+    }
+
     public int getServerPort()
     {
         return _driverRunnable.getServerPort();

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/199cc735/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
index ef93903..085326d 100644
--- 
a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
+++ 
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeerRunner.java
@@ -47,6 +47,7 @@ class TestAmqpPeerRunner implements Runnable
 
     private final Object _inputHandlingLock = new Object();
     private final TestFrameParser _testFrameParser;
+    private volatile boolean _suppressReadExceptionOnClose;
 
     private volatile Throwable _throwable;
 
@@ -76,6 +77,7 @@ class TestAmqpPeerRunner implements Runnable
     @Override
     public void run()
     {
+        boolean attemptingRead = false;
         try
         (
             Socket clientSocket = _serverSocket.accept();
@@ -90,8 +92,10 @@ class TestAmqpPeerRunner implements Runnable
             byte[] networkInputBytes = new byte[1024];
 
             LOGGER.trace("Attempting read");
+            attemptingRead = true;
             while((bytesRead = networkInputStream.read(networkInputBytes)) != 
-1)
             {
+                attemptingRead = false;
                 //prevent stop() from killing the socket while the frame 
parser might be using it handling input
                 synchronized(_inputHandlingLock)
                 {
@@ -102,13 +106,18 @@ class TestAmqpPeerRunner implements Runnable
                     _testFrameParser.input(networkInputByteBuffer);
                 }
                 LOGGER.trace("Attempting read");
+                attemptingRead = true;
             }
 
             LOGGER.trace("Exited read loop");
         }
         catch (Throwable t)
         {
-            if(!_serverSocket.isClosed())
+            if (attemptingRead && _suppressReadExceptionOnClose && t 
instanceof IOException)
+            {
+                LOGGER.debug("Caught exception during read, suppressing as 
expected: " + t, t);
+            }
+            else if(!_serverSocket.isClosed())
             {
                 LOGGER.error("Problem in peer", t);
                 _throwable = t;
@@ -196,4 +205,9 @@ class TestAmqpPeerRunner implements Runnable
     {
         return _clientSocket;
     }
+
+    public void setSuppressReadExceptionOnClose(boolean suppress)
+    {
+        _suppressReadExceptionOnClose = suppress;
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to