activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6077
Date Wed, 16 Dec 2015 14:39:54 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.13.x be38e9275 -> f6c242ad6


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

Making new values in ActiveMQObjectMessage transient which fixes HTTP
serialization

(cherry picked from commit b9dcb010f74675f6369f7e74b931b670e0ecab51)


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

Branch: refs/heads/activemq-5.13.x
Commit: f6c242ad6404c4b4cb2c66829dd48b86b32f3faf
Parents: be38e92
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Tue Dec 15 19:37:05 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Wed Dec 16 14:39:27 2015 +0000

----------------------------------------------------------------------
 .../activemq/command/ActiveMQObjectMessage.java | 22 ++++++++++++++---
 .../apache/activemq/command/ConsumerInfo.java   |  4 +--
 .../activemq/command/TransientInitializer.java  | 26 ++++++++++++++++++++
 .../transport/xstream/XStreamWireFormat.java    |  6 +++--
 4 files changed, 51 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/f6c242ad/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
index 5995a80..468ce79 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQObjectMessage.java
@@ -27,6 +27,7 @@ import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.InflaterInputStream;
 
@@ -66,15 +67,16 @@ import org.apache.activemq.wireformat.WireFormat;
  * @see javax.jms.StreamMessage
  * @see javax.jms.TextMessage
  */
-public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage {
+public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMessage, TransientInitializer
{
 
     public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_OBJECT_MESSAGE;
 
-    private List<String> trustedPackages = Arrays.asList(ClassLoadingAwareObjectInputStream.serializablePackages);
-    private boolean trustAllPackages = false;
+    private transient List<String> trustedPackages = Arrays.asList(ClassLoadingAwareObjectInputStream.serializablePackages);
+    private transient boolean trustAllPackages = false;
 
     protected transient Serializable object;
 
+    @Override
     public Message copy() {
         ActiveMQObjectMessage copy = new ActiveMQObjectMessage();
         copy(copy);
@@ -126,10 +128,12 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
         }
     }
 
+    @Override
     public byte getDataStructureType() {
         return DATA_STRUCTURE_TYPE;
     }
 
+    @Override
     public String getJMSXMimeType() {
         return "jms/object-message";
     }
@@ -146,6 +150,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
      *                 due to some internal error.
      */
 
+    @Override
     public void clearBody() throws JMSException {
         super.clearBody();
         this.object = null;
@@ -166,6 +171,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
      *                 read-only mode.
      */
 
+    @Override
     public void setObject(Serializable newObject) throws JMSException {
         checkReadOnlyBody();
         this.object = newObject;
@@ -183,6 +189,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
      * @return the serializable object containing this message's data
      * @throws JMSException
      */
+    @Override
     public Serializable getObject() throws JMSException {
         if (object == null && getContent() != null) {
             try {
@@ -216,11 +223,13 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
         storeContent();
     }
 
+    @Override
     public void clearMarshalledState() throws JMSException {
         super.clearMarshalledState();
         this.object = null;
     }
 
+    @Override
     public void onMessageRolledBack() {
         super.onMessageRolledBack();
 
@@ -235,6 +244,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
         super.compress();
     }
 
+    @Override
     public String toString() {
         try {
             getObject();
@@ -258,4 +268,10 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements
ObjectMess
     public void setTrustAllPackages(boolean trustAllPackages) {
         this.trustAllPackages = trustAllPackages;
     }
+
+    @Override
+    public void initTransients() {
+        trustedPackages = Arrays.asList(ClassLoadingAwareObjectInputStream.serializablePackages);
+        trustAllPackages = false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/f6c242ad/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java b/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java
index 16e6f8c2..5ccafab 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java
@@ -17,7 +17,6 @@
 package org.apache.activemq.command;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -30,7 +29,7 @@ import org.apache.activemq.state.CommandVisitor;
  * @openwire:marshaller code="5"
  *
  */
-public class ConsumerInfo extends BaseCommand {
+public class ConsumerInfo extends BaseCommand implements TransientInitializer {
 
     public static final byte DATA_STRUCTURE_TYPE = CommandTypes.CONSUMER_INFO;
 
@@ -527,6 +526,7 @@ public class ConsumerInfo extends BaseCommand {
         return result;
     }
 
+    @Override
     public void initTransients() {
         assignedGroupCount = new ConcurrentHashMap<>();
         lastDeliveredSequenceId = RemoveInfo.LAST_DELIVERED_UNSET;

http://git-wip-us.apache.org/repos/asf/activemq/blob/f6c242ad/activemq-client/src/main/java/org/apache/activemq/command/TransientInitializer.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/TransientInitializer.java
b/activemq-client/src/main/java/org/apache/activemq/command/TransientInitializer.java
new file mode 100644
index 0000000..b6d4a39
--- /dev/null
+++ b/activemq-client/src/main/java/org/apache/activemq/command/TransientInitializer.java
@@ -0,0 +1,26 @@
+/**
+ * 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.command;
+
+/**
+ *
+ *
+ */
+public interface TransientInitializer {
+
+    public void initTransients();
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/f6c242ad/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java
----------------------------------------------------------------------
diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java
b/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java
index f98fc61..8ddac9d 100755
--- a/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java
+++ b/activemq-http/src/main/java/org/apache/activemq/transport/xstream/XStreamWireFormat.java
@@ -24,9 +24,11 @@ import com.thoughtworks.xstream.converters.MarshallingContext;
 import com.thoughtworks.xstream.converters.UnmarshallingContext;
 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
+
 import org.apache.activemq.command.ConsumerInfo;
 import org.apache.activemq.command.MarshallAware;
 import org.apache.activemq.command.MessageDispatch;
+import org.apache.activemq.command.TransientInitializer;
 import org.apache.activemq.transport.stomp.XStreamSupport;
 import org.apache.activemq.transport.util.TextWireFormat;
 import org.apache.activemq.util.ByteSequence;
@@ -67,8 +69,8 @@ public class XStreamWireFormat extends TextWireFormat {
     @Override
     public Object unmarshalText(Reader reader) {
         Object val = getXStream().fromXML(reader);
-        if (val instanceof ConsumerInfo) {
-            ((ConsumerInfo)val).initTransients();
+        if (val instanceof TransientInitializer) {
+            ((TransientInitializer)val).initTransients();
         }
         return val;
     }


Mime
View raw message