qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject [1/2] qpid-broker-j git commit: QPID-8047: [Broker-J][AMQP 0-10] Fix NPE on receiving session.detach for unknown session
Date Tue, 05 Dec 2017 11:20:32 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 5b07dbf6b -> c2412ba4a


QPID-8047: [Broker-J][AMQP 0-10] Fix NPE on receiving session.detach for unknown session


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/c37376a2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/c37376a2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/c37376a2

Branch: refs/heads/master
Commit: c37376a2a8e139893d5442266c7bcb218ab18ce8
Parents: 5b07dbf
Author: Alex Rudyy <orudyy@apache.org>
Authored: Tue Dec 5 11:17:23 2017 +0000
Committer: Alex Rudyy <orudyy@apache.org>
Committed: Tue Dec 5 11:17:23 2017 +0000

----------------------------------------------------------------------
 .../v0_10/ServerConnectionDelegate.java         | 30 ++++++++++++++------
 .../qpid/tests/protocol/v0_10/Interaction.java  |  1 +
 .../qpid/tests/protocol/v0_10/SessionTest.java  |  2 --
 3 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c37376a2/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
index cab769f..43c3bf1 100644
--- a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
+++ b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/ServerConnectionDelegate.java
@@ -363,17 +363,31 @@ public class ServerConnectionDelegate extends MethodDelegate<ServerConnection>
i
     @Override
     public void sessionDetach(ServerConnection conn, SessionDetach dtc)
     {
-        stopAllSubscriptions(conn, dtc);
-        ServerSession ssn = conn.getSession(dtc.getChannel());
-        ssn.setClose(true);
-        ssn.sessionDetached(dtc.getName(), ssn.getDetachCode() == null? SessionDetachCode.NORMAL:
ssn.getDetachCode());
-        conn.unmap(ssn);
-        ssn.closed();
+        int channel = dtc.getChannel();
+        ServerSession ssn = conn.getSession(channel);
+        if (ssn != null)
+        {
+            stopAllSubscriptions(ssn);
+            ssn.setClose(true);
+            ssn.sessionDetached(dtc.getName(),
+                                ssn.getDetachCode() == null ? SessionDetachCode.NORMAL :
ssn.getDetachCode());
+            conn.unmap(ssn);
+            ssn.closed();
+        }
+        else
+        {
+            if(LOGGER.isDebugEnabled())
+            {
+                LOGGER.debug("SessionDetach received on unattached channel : {}", channel);
+            }
+            SessionDetached sessionDetached = new SessionDetached(dtc.getName(), SessionDetachCode.NOT_ATTACHED);
+            sessionDetached.setChannel(channel);
+            conn.invoke(sessionDetached);
+        }
     }
 
-    private void stopAllSubscriptions(ServerConnection conn, SessionDetach dtc)
+    private void stopAllSubscriptions(final ServerSession ssn)
     {
-        final ServerSession ssn = conn.getSession(dtc.getChannel());
         final Collection<ConsumerTarget_0_10> subs = ssn.getSubscriptions();
         for (ConsumerTarget_0_10 subscription_0_10 : subs)
         {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c37376a2/systests/protocol-tests-amqp-0-10/src/main/java/org/apache/qpid/tests/protocol/v0_10/Interaction.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-10/src/main/java/org/apache/qpid/tests/protocol/v0_10/Interaction.java
b/systests/protocol-tests-amqp-0-10/src/main/java/org/apache/qpid/tests/protocol/v0_10/Interaction.java
index 5d53a89..d636290 100644
--- a/systests/protocol-tests-amqp-0-10/src/main/java/org/apache/qpid/tests/protocol/v0_10/Interaction.java
+++ b/systests/protocol-tests-amqp-0-10/src/main/java/org/apache/qpid/tests/protocol/v0_10/Interaction.java
@@ -80,6 +80,7 @@ public class Interaction extends AbstractInteraction<Interaction>
         final BBDecoder decoder = new BBDecoder();
         decoder.init(buffer);
         dst.read(decoder);
+        dst.setChannel(src.getChannel());
         return dst;
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c37376a2/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/SessionTest.java
----------------------------------------------------------------------
diff --git a/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/SessionTest.java
b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/SessionTest.java
index 51de2c2..abb88e9 100644
--- a/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/SessionTest.java
+++ b/systests/protocol-tests-amqp-0-10/src/test/java/org/apache/qpid/tests/protocol/v0_10/SessionTest.java
@@ -92,8 +92,6 @@ public class SessionTest extends BrokerAdminUsingTestBase
         }
     }
 
-
-    @Ignore("QPID-8047")
     @Test
     @SpecificationTest(section = "9.session",
             description = "The transport MUST be attached in order to use any control other
than"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message