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 eeec0c07b0)
This commit is contained in:
Dejan Bosanac 2015-12-15 13:33:49 +01:00 committed by Christopher L. Shannon (cshannon)
parent 5a8cd29195
commit 9a0298f3e9
5 changed files with 34 additions and 9 deletions

View File

@ -58,8 +58,12 @@ public class ObjectMessageTest extends CamelSpringTestSupport {
assertCorrectObjectReceived(resultTrusted); assertCorrectObjectReceived(resultTrusted);
MockEndpoint resultCamel = resolveMandatoryEndpoint("mock:result-camel", MockEndpoint.class); MockEndpoint resultCamel = resolveMandatoryEndpoint("mock:result-camel", MockEndpoint.class);
resultCamel.expectedMessageCount(0); resultCamel.expectedMessageCount(1);
resultCamel.assertIsSatisfied(1, TimeUnit.SECONDS); resultCamel.assertIsNotSatisfied();
MockEndpoint resultEmpty = resolveMandatoryEndpoint("mock:result-empty", MockEndpoint.class);
resultEmpty.expectedMessageCount(1);
resultEmpty.assertIsNotSatisfied();
} }

View File

@ -31,6 +31,10 @@
<from uri="activemq-camel:topic:foo"/> <from uri="activemq-camel:topic:foo"/>
<to uri="mock:result-camel"/> <to uri="mock:result-camel"/>
</route> </route>
<route>
<from uri="activemq-empty:topic:foo"/>
<to uri="mock:result-empty"/>
</route>
<route> <route>
<from uri="activemq-trusted:topic:foo"/> <from uri="activemq-trusted:topic:foo"/>
<to uri="mock:result-trusted"/> <to uri="mock:result-trusted"/>
@ -75,6 +79,25 @@
<property name="configuration" ref="activemqConfig"/> <property name="configuration" ref="activemqConfig"/>
</bean> </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 --> <!-- configuration for activemq-trusted endpoint -->
<bean id="trustedConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory"> <bean id="trustedConnectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">

View File

@ -43,10 +43,7 @@ import org.apache.activemq.thread.TaskRunnerFactory;
import org.apache.activemq.transport.Transport; import org.apache.activemq.transport.Transport;
import org.apache.activemq.transport.TransportFactory; import org.apache.activemq.transport.TransportFactory;
import org.apache.activemq.transport.TransportListener; import org.apache.activemq.transport.TransportListener;
import org.apache.activemq.util.IdGenerator; import org.apache.activemq.util.*;
import org.apache.activemq.util.IntrospectionSupport;
import org.apache.activemq.util.JMSExceptionSupport;
import org.apache.activemq.util.URISupport;
import org.apache.activemq.util.URISupport.CompositeData; import org.apache.activemq.util.URISupport.CompositeData;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -180,7 +177,7 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
protected int xaAckMode = -1; // ensure default init before setting via brokerUrl introspection in sub class protected int xaAckMode = -1; // ensure default init before setting via brokerUrl introspection in sub class
private boolean rmIdFromConnectionId = false; private boolean rmIdFromConnectionId = false;
private boolean consumerExpiryCheckEnabled = true; private boolean consumerExpiryCheckEnabled = true;
private List<String> trustedPackages = new ArrayList<String>(); private List<String> trustedPackages = Arrays.asList(ClassLoadingAwareObjectInputStream.serializablePackages);
private boolean trustAllPackages = false; private boolean trustAllPackages = false;
// ///////////////////////////////////////////// // /////////////////////////////////////////////

View File

@ -25,6 +25,7 @@ import java.io.ObjectOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.zip.DeflaterOutputStream; import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream; 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; 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; private boolean trustAllPackages = false;
protected transient Serializable object; protected transient Serializable object;

View File

@ -109,7 +109,7 @@ public class ClassLoadingAwareObjectInputStream extends ObjectInputStream {
} }
} }
if (!found) { 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.");
} }
} }
} }