You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/03/12 15:57:06 UTC

[1/3] activemq-6 git commit: ACTIVEMQ6-55: add a test of the listener method throwing the NPE

Repository: activemq-6
Updated Branches:
  refs/heads/master d47fba425 -> 341e49e3a


ACTIVEMQ6-55: add a test of the listener method throwing the NPE


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/7ef95ae9
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/7ef95ae9
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/7ef95ae9

Branch: refs/heads/master
Commit: 7ef95ae977f7c9dcaf13da2959feafb897e8ea80
Parents: 983effc
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Mar 12 14:25:57 2015 +0000
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 12 10:54:17 2015 -0400

----------------------------------------------------------------------
 .../plug/context/AbstractConnectionContext.java |   3 +-
 .../context/AbstractConnectionContextTest.java  | 114 +++++++++++++++++++
 2 files changed, 116 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/7ef95ae9/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
----------------------------------------------------------------------
diff --git a/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java b/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
index 20b2d8b..3d0d0bc 100644
--- a/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
+++ b/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
@@ -47,12 +47,13 @@ public abstract class AbstractConnectionContext extends ProtonInitializable impl
 
    private final Map<Session, AbstractProtonSessionContext> sessions = new ConcurrentHashMap<>();
 
+   protected LocalListener listener = new LocalListener();
 
    public AbstractConnectionContext(AMQPConnectionCallback connectionCallback)
    {
       this.connectionCallback = connectionCallback;
       connectionCallback.setConnection(this);
-      handler.addEventHandler(new LocalListener());
+      handler.addEventHandler(listener);
    }
 
    public SASLResult getSASLResult()

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/7ef95ae9/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
----------------------------------------------------------------------
diff --git a/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java b/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
new file mode 100644
index 0000000..2396b1e
--- /dev/null
+++ b/activemq-protocols/activemq-proton-plug/src/test/java/org/proton/plug/context/AbstractConnectionContextTest.java
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.proton.plug.context;
+
+import io.netty.buffer.ByteBuf;
+
+import org.apache.qpid.proton.engine.Connection;
+import org.apache.qpid.proton.engine.Link;
+import org.apache.qpid.proton.engine.Session;
+import org.junit.Test;
+import org.proton.plug.AMQPConnectionCallback;
+import org.proton.plug.AMQPConnectionContext;
+import org.proton.plug.AMQPSessionCallback;
+import org.proton.plug.ServerSASL;
+import org.proton.plug.exceptions.ActiveMQAMQPException;
+import org.proton.plug.handler.EventHandler;
+
+public class AbstractConnectionContextTest
+{
+
+   @Test
+   public void testListenerDoesntThrowNPEWhenClosingLinkWithNullContext() throws Exception
+   {
+      TestConnectionContext connectionContext = new TestConnectionContext(new TestConnectionCallback());
+      EventHandler listener = connectionContext.getListener();
+
+      Connection protonConnection = Connection.Factory.create();
+      Session protonSession = protonConnection.session();
+      Link link = protonSession.receiver("link");
+
+      link.setContext(null);
+
+      listener.onRemoteClose(link);
+   }
+
+   private class TestConnectionContext extends AbstractConnectionContext
+   {
+
+      public TestConnectionContext(AMQPConnectionCallback connectionCallback)
+      {
+         super(connectionCallback);
+      }
+
+      @Override
+      protected void remoteLinkOpened(Link link) throws Exception
+      {
+
+      }
+
+      @Override
+      protected AbstractProtonSessionContext newSessionExtension(Session realSession) throws ActiveMQAMQPException
+      {
+         return null;
+      }
+
+      public EventHandler getListener()
+      {
+         return listener;
+      }
+   }
+
+   private class TestConnectionCallback implements AMQPConnectionCallback
+   {
+      @Override
+      public void close()
+      {
+
+      }
+
+      @Override
+      public void onTransport(ByteBuf bytes, AMQPConnectionContext connection)
+      {
+
+      }
+
+      @Override
+      public AMQPSessionCallback createSessionCallback(AMQPConnectionContext connection)
+      {
+         return null;
+      }
+
+      @Override
+      public void setConnection(AMQPConnectionContext connection)
+      {
+
+      }
+
+      @Override
+      public AMQPConnectionContext getConnection()
+      {
+         return null;
+      }
+
+      @Override
+      public ServerSASL[] getSASLMechnisms()
+      {
+         return null;
+      }
+   }
+}


[2/3] activemq-6 git commit: ACTIVEMQ6-55: prevent NPE when closing a link that didnt get as far as having a context added

Posted by cl...@apache.org.
ACTIVEMQ6-55: prevent NPE when closing a link that didnt get as far as having a context added


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/983effca
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/983effca
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/983effca

Branch: refs/heads/master
Commit: 983effca9d9ab95f9babe488847cd75b68cc24a8
Parents: d47fba4
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Mar 12 11:42:29 2015 +0000
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 12 10:54:17 2015 -0400

----------------------------------------------------------------------
 .../org/proton/plug/context/AbstractConnectionContext.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/983effca/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
----------------------------------------------------------------------
diff --git a/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java b/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
index 35d52bf..20b2d8b 100644
--- a/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
+++ b/activemq-protocols/activemq-proton-plug/src/main/java/org/proton/plug/context/AbstractConnectionContext.java
@@ -255,7 +255,11 @@ public abstract class AbstractConnectionContext extends ProtonInitializable impl
       public void onRemoteClose(Link link) throws Exception
       {
          link.close();
-         ((ProtonDeliveryHandler) link.getContext()).close();
+         ProtonDeliveryHandler linkContext = (ProtonDeliveryHandler) link.getContext();
+         if (linkContext != null)
+         {
+            linkContext.close();
+         }
       }
 
 


[3/3] activemq-6 git commit: This closes #176 on proton changes

Posted by cl...@apache.org.
This closes #176 on proton changes

Committs included on this:
commit 7ef95ae977f7c9dcaf13da2959feafb897e8ea80
commit 983effca9d9ab95f9babe488847cd75b68cc24a8


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/341e49e3
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/341e49e3
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/341e49e3

Branch: refs/heads/master
Commit: 341e49e3a5a98f418802fccdc1dc06a9b4bbf333
Parents: 7ef95ae
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu Mar 12 10:56:19 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Mar 12 10:56:19 2015 -0400

----------------------------------------------------------------------

----------------------------------------------------------------------