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 2018/01/17 17:48:32 UTC

[3/3] activemq-artemis git commit: ARTEMIS-1609 fix JMS destination s11n compatibility

ARTEMIS-1609 fix JMS destination s11n compatibility


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

Branch: refs/heads/master
Commit: 1aa7b5c038c3791f5dd0e7fdc859d74a63b8d76d
Parents: 60055d7
Author: Justin Bertram <jb...@apache.org>
Authored: Tue Jan 16 09:15:00 2018 -0600
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Jan 17 12:31:27 2018 -0500

----------------------------------------------------------------------
 .../artemis/jms/client/ActiveMQDestination.java | 43 ++++++++++++++++----
 .../src/main/resources/serial/jbmserial.groovy  | 10 +++++
 .../src/main/resources/serial/serial.groovy     | 14 ++++++-
 .../tests/compatibility/SerializationTest.java  |  8 ++--
 4 files changed, 60 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1aa7b5c0/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java
index 7750564..8c7a5a0 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQDestination.java
@@ -241,6 +241,18 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
     */
    private SimpleString simpleAddress;
 
+   /**
+    * Needed for serialization backwards compatibility.
+    */
+   @Deprecated
+   private String address;
+
+   /**
+    * The "JMS" name of the destination. Needed for serialization backwards compatibility.
+    */
+   @Deprecated
+   private String name;
+
    private final boolean temporary;
 
    private final boolean queue;
@@ -254,7 +266,13 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
    protected ActiveMQDestination(final String address,
                                  final TYPE type,
                                  final ActiveMQSession session) {
-      this.simpleAddress = SimpleString.toSimpleString(address);
+      this(SimpleString.toSimpleString(address), type, session);
+   }
+
+   protected ActiveMQDestination(final SimpleString address,
+                                 final TYPE type,
+                                 final ActiveMQSession session) {
+      this.simpleAddress = address;
 
       this.thetype = type;
 
@@ -265,18 +283,24 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
       this.queue = TYPE.isQueue(type);
    }
 
-   protected ActiveMQDestination(final SimpleString address,
+   @Deprecated
+   protected ActiveMQDestination(final String address,
+                                 final String name,
                                  final TYPE type,
                                  final ActiveMQSession session) {
-      this.simpleAddress = address;
-
-      this.thetype = type;
+      this(SimpleString.toSimpleString(address), name, type, session);
+   }
 
-      this.session = session;
+   @Deprecated
+   protected ActiveMQDestination(final SimpleString address,
+                                 final String name,
+                                 final TYPE type,
+                                 final ActiveMQSession session) {
+      this(address, type, session);
 
-      this.temporary = TYPE.isTemporary(type);
+      this.name = name;
 
-      this.queue = TYPE.isQueue(type);
+      this.address = simpleAddress != null ? simpleAddress.toString() : null;
    }
 
    public void setAddress(String address) {
@@ -287,6 +311,7 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
       if (address == null) {
          throw new IllegalArgumentException("address cannot be null");
       }
+      this.address = address.toString();
       this.simpleAddress = address;
    }
 
@@ -319,7 +344,7 @@ public class ActiveMQDestination extends JNDIStorable implements Destination, Se
    }
 
    public String getName() {
-      return simpleAddress.toString();
+      return name != null ? name : getAddress();
    }
 
    public boolean isTemporary() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1aa7b5c0/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy b/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy
index 159cce9..b80dddb 100644
--- a/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy
+++ b/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy
@@ -31,6 +31,7 @@ import org.apache.activemq.artemis.jms.client.*
 
 file = arg[0]
 method = arg[1]
+version = arg[2]
 System.out.println("File::" + file);
 
 
@@ -49,6 +50,11 @@ if (method.equals("write")) {
     topic = new ActiveMQTopic("topic")
     temporary = ActiveMQDestination.createTemporaryQueue("whatever")
     temporaryTopic = ActiveMQDestination.createTemporaryTopic("whatever")
+    if (version.equals("ARTEMIS-SNAPSHOT")) {
+        destination = new ActiveMQDestination("address", "name", ActiveMQDestination.TYPE.DESTINATION, null)
+    } else if (version.equals("ARTEMIS-155")) {
+        destination = new ActiveMQDestination("address", "name", false, true, null)
+    }
 
     Marshaller marshaller = factory.createMarshaller(configuration)
     FileOutputStream fileOutputStream = new FileOutputStream(file)
@@ -58,6 +64,7 @@ if (method.equals("write")) {
     marshaller.writeObject(topic)
     marshaller.writeObject(temporary)
     marshaller.writeObject(temporaryTopic)
+    marshaller.writeObject(destination)
     marshaller.finish()
     fileOutputStream.close();
 } else {
@@ -69,10 +76,13 @@ if (method.equals("write")) {
     topic = unmarshaller.readObject()
     temporary = unmarshaller.readObject()
     temporaryTopic = unmarshaller.readObject()
+    destination = unmarshaller.readObject()
 }
 
 GroovyRun.assertTrue(!cf.getServerLocator().isBlockOnDurableSend());
 GroovyRun.assertEquals(1048576, cf.getServerLocator().getConfirmationWindowSize());
+GroovyRun.assertEquals(destination.getName(), "name")
+GroovyRun.assertEquals(destination.getAddress(), "address")
 
 Connection connection = cf.createConnection();
 Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1aa7b5c0/tests/compatibility-tests/src/main/resources/serial/serial.groovy
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/main/resources/serial/serial.groovy b/tests/compatibility-tests/src/main/resources/serial/serial.groovy
index 0756fb3..f5a3e5f 100644
--- a/tests/compatibility-tests/src/main/resources/serial/serial.groovy
+++ b/tests/compatibility-tests/src/main/resources/serial/serial.groovy
@@ -24,18 +24,25 @@ import org.apache.activemq.artemis.jms.client.*
 
 file = arg[0]
 method = arg[1]
-System.out.println("File::" + file);
+version = arg[2]
+System.out.println("File::" + file)
 
 
 if (method.equals("write")) {
     cf = new ActiveMQConnectionFactory("tcp://localhost:61616?confirmationWindowSize=1048576&blockOnDurableSend=false");
     queue = new ActiveMQQueue("queue");
     topic = new ActiveMQTopic("topic")
+    if (version.equals("ARTEMIS-SNAPSHOT")) {
+        destination = new ActiveMQDestination("address", "name", ActiveMQDestination.TYPE.DESTINATION, null)
+    } else if (version.equals("ARTEMIS-155")) {
+        destination = new ActiveMQDestination("address", "name", false, true, null)
+    }
 
     ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(file));
     objectOutputStream.writeObject(cf);
     objectOutputStream.writeObject(queue)
     objectOutputStream.writeObject(topic)
+    objectOutputStream.writeObject(destination)
     objectOutputStream.close();
 } else {
     ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(file))
@@ -43,11 +50,14 @@ if (method.equals("write")) {
     cf = inputStream.readObject();
     queue = inputStream.readObject()
     topic = inputStream.readObject()
+    destination = inputStream.readObject()
     inputStream.close();
 }
 
 GroovyRun.assertTrue(!cf.getServerLocator().isBlockOnDurableSend());
-GroovyRun.assertEquals(1048576, cf.getServerLocator().getConfirmationWindowSize());
+GroovyRun.assertEquals(1048576, cf.getServerLocator().getConfirmationWindowSize())
+GroovyRun.assertEquals(destination.getName(), "name")
+GroovyRun.assertEquals(destination.getAddress(), "address")
 
 Connection connection = cf.createConnection();
 Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1aa7b5c0/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
----------------------------------------------------------------------
diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
index 3358bbc..2c017f2 100644
--- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
+++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/SerializationTest.java
@@ -91,15 +91,15 @@ public class SerializationTest extends VersionedBaseTest {
    @Test
    public void testSerializeFactory() throws Throwable {
       File file = serverFolder.newFile("objects.ser");
-      callScript(senderClassloader, "serial/serial.groovy", file.getAbsolutePath(), "write");
-      callScript(receiverClassloader, "serial/serial.groovy", file.getAbsolutePath(), "read");
+      callScript(senderClassloader, "serial/serial.groovy", file.getAbsolutePath(), "write", sender);
+      callScript(receiverClassloader, "serial/serial.groovy", file.getAbsolutePath(), "read", receiver);
    }
 
    @Test
    public void testJBMSerializeFactory() throws Throwable {
       File file = serverFolder.newFile("objectsjbm.ser");
-      callScript(senderClassloader, "serial/jbmserial.groovy", file.getAbsolutePath(), "write");
-      callScript(receiverClassloader, "serial/jbmserial.groovy", file.getAbsolutePath(), "read");
+      callScript(senderClassloader, "serial/jbmserial.groovy", file.getAbsolutePath(), "write", sender);
+      callScript(receiverClassloader, "serial/jbmserial.groovy", file.getAbsolutePath(), "read", receiver);
    }
 
 }