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 - define default values (based on system property) for connection factory and object message
Date Tue, 15 Dec 2015 12:52:20 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.13.x 5e02e305e -> 9aa6bdcf6


https://issues.apache.org/jira/browse/AMQ-6077 - define default values (based on system property)
for connection factory and object message

(cherry picked from commit eeec0c07b06e6121ed33e20f7c663214538d0da1)


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

Branch: refs/heads/activemq-5.13.x
Commit: 9aa6bdcf6ef006a85873366161b73fec87d18f4e
Parents: 5e02e30
Author: Dejan Bosanac <dejan@nighttale.net>
Authored: Tue Dec 15 13:33:49 2015 +0100
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Tue Dec 15 12:52:00 2015 +0000

----------------------------------------------------------------------
 .../activemq/camel/ObjectMessageTest.java       |  8 +++++--
 .../activemq/camel/jms-object-message.xml       | 23 ++++++++++++++++++++
 .../activemq/ActiveMQConnectionFactory.java     |  7 ++----
 .../activemq/command/ActiveMQObjectMessage.java |  3 ++-
 .../ClassLoadingAwareObjectInputStream.java     |  2 +-
 5 files changed, 34 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/9aa6bdcf/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
index 226cfd3..8cb5e0f 100644
--- a/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
+++ b/activemq-camel/src/test/java/org/apache/activemq/camel/ObjectMessageTest.java
@@ -58,8 +58,12 @@ public class ObjectMessageTest extends CamelSpringTestSupport {
         assertCorrectObjectReceived(resultTrusted);
 
         MockEndpoint resultCamel = resolveMandatoryEndpoint("mock:result-camel", MockEndpoint.class);
-        resultCamel.expectedMessageCount(0);
-        resultCamel.assertIsSatisfied(1, TimeUnit.SECONDS);
+        resultCamel.expectedMessageCount(1);
+        resultCamel.assertIsNotSatisfied();
+
+        MockEndpoint resultEmpty = resolveMandatoryEndpoint("mock:result-empty", MockEndpoint.class);
+        resultEmpty.expectedMessageCount(1);
+        resultEmpty.assertIsNotSatisfied();
 
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/9aa6bdcf/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
----------------------------------------------------------------------
diff --git a/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
b/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
index a4534c0..7d7eca8 100644
--- a/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
+++ b/activemq-camel/src/test/resources/org/apache/activemq/camel/jms-object-message.xml
@@ -32,6 +32,10 @@
             <to uri="mock:result-camel"/>
         </route>
         <route>
+            <from uri="activemq-empty:topic:foo"/>
+            <to uri="mock:result-empty"/>
+        </route>
+        <route>
             <from uri="activemq-trusted:topic:foo"/>
             <to uri="mock:result-trusted"/>
         </route>
@@ -75,6 +79,25 @@
         <property name="configuration" ref="activemqConfig"/>
     </bean>
 
+    <!-- configuration for activemq-empty endpoint -->
+
+    <bean id="emptyConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
+        <property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
+        <property name="trustedPackages">
+            <list>
+                <value></value>
+            </list>
+        </property>
+    </bean>
+
+    <bean id="emptyConfig" class="org.apache.camel.component.jms.JmsConfiguration">
+        <property name="connectionFactory" ref="emptyConnectionFactory"/>
+    </bean>
+
+    <bean id="activemq-empty" class="org.apache.activemq.camel.component.ActiveMQComponent">
+        <property name="configuration" ref="emptyConfig"/>
+    </bean>
+
     <!-- configuration for activemq-trusted endpoint -->
 
     <bean id="trustedConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">

http://git-wip-us.apache.org/repos/asf/activemq/blob/9aa6bdcf/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
index 171c8d4..4d958e6 100755
--- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java
@@ -44,10 +44,7 @@ import org.apache.activemq.thread.TaskRunnerFactory;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
 import org.apache.activemq.transport.TransportListener;
-import org.apache.activemq.util.IdGenerator;
-import org.apache.activemq.util.IntrospectionSupport;
-import org.apache.activemq.util.JMSExceptionSupport;
-import org.apache.activemq.util.URISupport;
+import org.apache.activemq.util.*;
 import org.apache.activemq.util.URISupport.CompositeData;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -181,7 +178,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements
Conne
     protected int xaAckMode = -1; // ensure default init before setting via brokerUrl introspection
in sub class
     private boolean rmIdFromConnectionId = false;
     private boolean consumerExpiryCheckEnabled = true;
-    private List<String> trustedPackages = new ArrayList<String>();
+    private List<String> trustedPackages = Arrays.asList(ClassLoadingAwareObjectInputStream.serializablePackages);
     private boolean trustAllPackages = false;
 
     // /////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/activemq/blob/9aa6bdcf/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 0d762de..5995a80 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
@@ -25,6 +25,7 @@ import java.io.ObjectOutputStream;
 import java.io.OutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.InflaterInputStream;
@@ -69,7 +70,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
 
     public static final byte DATA_STRUCTURE_TYPE = CommandTypes.ACTIVEMQ_OBJECT_MESSAGE;
 
-    private List<String> trustedPackages = new ArrayList<String>();
+    private List<String> trustedPackages = Arrays.asList(ClassLoadingAwareObjectInputStream.serializablePackages);
     private boolean trustAllPackages = false;
 
     protected transient Serializable object;

http://git-wip-us.apache.org/repos/asf/activemq/blob/9aa6bdcf/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 9d05108..0453939 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
@@ -109,7 +109,7 @@ public class ClassLoadingAwareObjectInputStream extends ObjectInputStream
{
                    }
                }
                if (!found) {
-                   throw new ClassNotFoundException("Forbidden " + clazz + "! This class
is not allowed to be serialized. Add package with 'org.apache.activemq.SERIALIZABLE_PACKAGES'
system property.");
+                   throw new ClassNotFoundException("Forbidden " + clazz + "! This class
is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html
for more information on how to configure trusted classes.");
                }
             }
         }


Mime
View raw message