activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5921
Date Fri, 07 Aug 2015 15:01:04 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 70ef9b7e3 -> 41ee3ec8d


https://issues.apache.org/jira/browse/AMQ-5921

Add back support for type void and test.

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

Branch: refs/heads/master
Commit: 41ee3ec8dea1df70cb12f722dcf797f50b24fc54
Parents: 70ef9b7
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Aug 7 11:00:44 2015 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Aug 7 11:00:44 2015 -0400

----------------------------------------------------------------------
 .../ClassLoadingAwareObjectInputStream.java     |   4 +
 .../activemq/bugs/AMQ5921MessagePayload.java    |  33 ++++++
 .../org/apache/activemq/bugs/AMQ5921Test.java   | 117 +++++++++++++++++++
 3 files changed, 154 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/41ee3ec8/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
b/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
index ca4d8a3..74dcdf8 100644
--- a/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
+++ b/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
@@ -38,11 +38,13 @@ public class ClassLoadingAwareObjectInputStream extends ObjectInputStream
{
         inLoader = in.getClass().getClassLoader();
     }
 
+    @Override
     protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException,
ClassNotFoundException {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         return load(classDesc.getName(), cl, inLoader);
     }
 
+    @Override
     protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException
{
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         Class[] cinterfaces = new Class[interfaces.length];
@@ -144,6 +146,8 @@ public class ClassLoadingAwareObjectInputStream extends ObjectInputStream
{
             return Double.class;
         } else if ("double".equals(name)) {
             return double.class;
+        } else if ("void".equals(name)) {
+            return void.class;
         }
 
         return null;

http://git-wip-us.apache.org/repos/asf/activemq/blob/41ee3ec8/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921MessagePayload.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921MessagePayload.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921MessagePayload.java
new file mode 100644
index 0000000..3558f76
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921MessagePayload.java
@@ -0,0 +1,33 @@
+/**
+ * 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.apache.activemq.bugs;
+
+import java.io.Serializable;
+
+public class AMQ5921MessagePayload implements Serializable {
+    private static final long serialVersionUID = 1886695392106889605L;
+
+    protected Class<?> field1;
+
+    public Class<?> getField1() {
+        return field1;
+    }
+
+    public void setField1(Class<?> field1) {
+        this.field1 = field1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/41ee3ec8/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921Test.java
new file mode 100644
index 0000000..428782a
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ5921Test.java
@@ -0,0 +1,117 @@
+/**
+ * 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.apache.activemq.bugs;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQObjectMessage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AMQ5921Test {
+
+    private static Logger LOG = LoggerFactory.getLogger(AMQ5921Test.class);
+
+    private ActiveMQConnection connection;
+    private BrokerService broker;
+    private String connectionUri;
+
+    @Rule
+    public TestName name = new TestName();
+
+    @Test
+    public void testVoidSupport() throws Exception {
+        sendMessage();
+
+        connection.start();
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination destination = session.createQueue(name.getMethodName());
+
+        MessageConsumer consumer = session.createConsumer(destination);
+        ActiveMQObjectMessage msg = (ActiveMQObjectMessage) consumer.receive();
+        AMQ5921MessagePayload payload = (AMQ5921MessagePayload) msg.getObject();
+        LOG.info("Received: {}", payload.getField1());
+
+        session.close();
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        broker = new BrokerService();
+        broker.setUseJmx(false);
+        broker.setPersistent(false);
+        broker.addConnector("tcp://localhost:0");
+        broker.start();
+        broker.waitUntilStarted();
+
+        connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
+
+        connection = createConnection();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (connection != null) {
+            try {
+                connection.close();
+            } catch (Exception e) {}
+        }
+
+        if (broker != null) {
+            broker.stop();
+            broker.waitUntilStopped();
+        }
+    }
+
+    protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
+        return new ActiveMQConnectionFactory(connectionUri);
+    }
+
+    protected ActiveMQConnection createConnection() throws Exception {
+        return (ActiveMQConnection) createConnectionFactory().createConnection();
+    }
+
+    private void sendMessage() throws Exception {
+        AMQ5921MessagePayload msgPayload = new AMQ5921MessagePayload();
+        msgPayload.setField1(void.class);  // <-- does not work
+
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination destination = session.createQueue(name.getMethodName());
+        MessageProducer producer = session.createProducer(destination);
+        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+        ObjectMessage message = session.createObjectMessage();
+        message.setObject(msgPayload);
+
+        producer.send(message);
+        session.close();
+    }
+}


Mime
View raw message