mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-6077 - define default values (based on system property) for connection factory and object message
This commit is contained in:
parent
9e7fae0d83
commit
eeec0c07b0
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
<from uri="activemq-camel:topic:foo"/>
|
||||
<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"/>
|
||||
|
@ -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">
|
||||
|
|
|
@ -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;
|
||||
|
||||
// /////////////////////////////////////////////
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue