diff -Nru activemq-5.16.0/activemq-all/pom.xml activemq-5.16.1/activemq-all/pom.xml --- activemq-5.16.0/activemq-all/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-all/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -14,7 +14,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-all diff -Nru activemq-5.16.0/activemq-amqp/pom.xml activemq-5.16.1/activemq-amqp/pom.xml --- activemq-5.16.0/activemq-amqp/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-amqp/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-amqp diff -Nru activemq-5.16.0/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java activemq-5.16.1/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java --- activemq-5.16.0/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/protocol/AmqpSender.java 2021-01-14 13:00:24.000000000 +0000 @@ -280,7 +280,7 @@ // the DLQ. If a custom redelivery policy is used on the broker the message // can still be redelivered based on the configation of that policy. LOG.trace("onDelivery: Rejected state = {}, message poisoned.", state); - settle(delivery, MessageAck.POSION_ACK_TYPE); + settle(delivery, MessageAck.POISON_ACK_TYPE); } else if (state instanceof Released) { LOG.trace("onDelivery: Released state = {}", state); // re-deliver && don't increment the counter. @@ -297,7 +297,7 @@ if (undeliverableHere != null && undeliverableHere) { // receiver does not want the message.. // perhaps we should DLQ it? - ackType = MessageAck.POSION_ACK_TYPE; + ackType = MessageAck.POISON_ACK_TYPE; } settle(delivery, ackType); } Binary files /tmp/tmpuvqhec/1y0pmNA3Cr/activemq-5.16.0/activemq-amqp/src/test/resources/alternative.keystore and /tmp/tmpuvqhec/LpAcg9TglM/activemq-5.16.1/activemq-amqp/src/test/resources/alternative.keystore differ Binary files /tmp/tmpuvqhec/1y0pmNA3Cr/activemq-5.16.0/activemq-amqp/src/test/resources/keystore and /tmp/tmpuvqhec/LpAcg9TglM/activemq-5.16.1/activemq-amqp/src/test/resources/keystore differ diff -Nru activemq-5.16.0/activemq-amqp/src/test/resources/README.txt activemq-5.16.1/activemq-amqp/src/test/resources/README.txt --- activemq-5.16.0/activemq-amqp/src/test/resources/README.txt 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-amqp/src/test/resources/README.txt 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,17 @@ +# The various keystores/truststores here were created with the following commands. +# You can source this file to run it as a sript to regenerate them. + +# NOTE: This module isnt a good example of how to generate keypairs and use keystores. This should be replaced, +# but needs various module-wide changes to the tests and their client/brokers use of keys/certs/trust. + +# Clean up existing files: +# ------------------------ +rm -f keystore alternative.keystore + +# Create a key pair +# ----------------- +keytool -storetype jks -keystore keystore -storepass password -keypass password -alias activemq -genkey -keyalg "RSA" -keysize 2048 -dname "O=ActiveMQ,CN=localhost" -validity 9999 + +# Create an alternative keypair, to allow use in provoking 'failure to trust' it when matched against the above +# ---------------------------------------------------------------------------------------------------------------------- +keytool -storetype jks -keystore alternative.keystore -storepass password -keypass password -alias alternative -genkey -keyalg "RSA" -keysize 2048 -dname "O=Alternative,CN=localhost" -validity 9999 diff -Nru activemq-5.16.0/activemq-blueprint/pom.xml activemq-5.16.1/activemq-blueprint/pom.xml --- activemq-5.16.0/activemq-blueprint/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-blueprint/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-blueprint diff -Nru activemq-5.16.0/activemq-broker/pom.xml activemq-5.16.1/activemq-broker/pom.xml --- activemq-5.16.0/activemq-broker/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-broker diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java 2021-01-14 13:00:24.000000000 +0000 @@ -203,6 +203,7 @@ private final AtomicBoolean preShutdownHooksInvoked = new AtomicBoolean(false); private BrokerPlugin[] plugins; private boolean keepDurableSubsActive = true; + private boolean enableMessageExpirationOnActiveDurableSubs = false; private boolean useVirtualTopics = true; private boolean useMirroredQueues = false; private boolean useTempMirroredQueues = true; @@ -1729,6 +1730,14 @@ public void setKeepDurableSubsActive(boolean keepDurableSubsActive) { this.keepDurableSubsActive = keepDurableSubsActive; } + + public boolean isEnableMessageExpirationOnActiveDurableSubs() { + return enableMessageExpirationOnActiveDurableSubs; + } + + public void setEnableMessageExpirationOnActiveDurableSubs(boolean enableMessageExpirationOnActiveDurableSubs) { + this.enableMessageExpirationOnActiveDurableSubs = enableMessageExpirationOnActiveDurableSubs; + } public boolean isUseVirtualTopics() { return useVirtualTopics; diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java 2021-01-14 13:00:24.000000000 +0000 @@ -202,6 +202,7 @@ @Override public Object invoke(String s, Object[] objects, String[] strings) throws MBeanException, ReflectionException { + objects = (objects == null) ? new Object[]{} : objects; JMXAuditLogEntry entry = null; if (audit != OFF) { Subject subject = Subject.getSubject(AccessController.getContext()); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationsViewFilter.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationsViewFilter.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationsViewFilter.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/DestinationsViewFilter.java 2021-01-14 13:00:24.000000000 +0000 @@ -196,7 +196,7 @@ Object leftValue = getter.invoke(left.getValue()); Object rightValue = getter.invoke(right.getValue()); if (leftValue instanceof Comparable && rightValue instanceof Comparable) { - if (getSortOrder().toLowerCase().equals("desc")) { + if (getSortOrder().equalsIgnoreCase("desc")) { return ((Comparable) rightValue).compareTo(leftValue); } else { return ((Comparable) leftValue).compareTo(rightValue); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java 2021-01-14 13:00:24.000000000 +0000 @@ -24,10 +24,14 @@ import javax.management.openmbean.TabularDataSupport; import javax.management.openmbean.TabularType; +import org.apache.activemq.Message; +import org.apache.activemq.ScheduledMessage; import org.apache.activemq.broker.jmx.OpenTypeSupport.OpenTypeFactory; import org.apache.activemq.broker.scheduler.Job; import org.apache.activemq.broker.scheduler.JobScheduler; import org.apache.activemq.broker.scheduler.JobSupport; +import org.apache.activemq.openwire.OpenWireFormat; +import org.apache.activemq.util.ByteSequence; /** * MBean object that can be used to manage a single instance of a JobScheduler. The object @@ -77,6 +81,24 @@ } @Override + public int getDelayedMessageCount() throws Exception { + int counter = 0; + OpenWireFormat wireFormat = new OpenWireFormat(); + for (Job job : jobScheduler.getAllJobs()) { + Message msg = (Message) wireFormat.unmarshal(new ByteSequence(job.getPayload())); + if (msg.getLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY) > 0) { + counter++; + } + } + return counter; + } + + @Override + public int getScheduledMessageCount() throws Exception { + return this.jobScheduler.getAllJobs().size(); + } + + @Override public TabularData getNextScheduleJobs() throws Exception { OpenTypeFactory factory = OpenTypeSupport.getFactory(Job.class); CompositeType ct = factory.getCompositeType(); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java 2021-01-14 13:00:24.000000000 +0000 @@ -122,4 +122,24 @@ @MBeanInfo("get the scheduled Jobs in the Store within the time range. Not HTML friendly ") public abstract TabularData getAllJobs(@MBeanInfo("start: yyyy-MM-dd hh:mm:ss")String start,@MBeanInfo("finish: yyyy-MM-dd hh:mm:ss")String finish)throws Exception; + /** + * Get the number of messages in the scheduler. + * + * @return the number of messages in the scheduler. + * + * @throws Exception if an error occurs while querying the scheduler store. + */ + @MBeanInfo("get the number of scheduled message (basically message in the scheduler") + public abstract int getScheduledMessageCount() throws Exception; + + /** + * Get the number of delayed messages. + * + * @return the number of delayed messages. + * + * @throws Exception if an error occurs while querying the scheduler store. + */ + @MBeanInfo("get the number of delayed message") + public abstract int getDelayedMessageCount() throws Exception; + } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/BaseDestination.java 2021-01-14 13:00:24.000000000 +0000 @@ -894,7 +894,7 @@ Throwable cause = new Throwable(DUPLICATE_FROM_STORE_MSG_PREFIX + destination); message.setRegionDestination(this); broker.getRoot().sendToDeadLetterQueue(connectionContext, message, null, cause); - MessageAck messageAck = new MessageAck(message, MessageAck.POSION_ACK_TYPE, 1); + MessageAck messageAck = new MessageAck(message, MessageAck.POISON_ACK_TYPE, 1); messageAck.setPoisonCause(cause); try { acknowledge(connectionContext, subscription, messageAck, message); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java 2021-01-14 13:00:24.000000000 +0000 @@ -58,6 +58,7 @@ private final ConcurrentMap durableDestinations = new ConcurrentHashMap(); private final SubscriptionKey subscriptionKey; private boolean keepDurableSubsActive; + private boolean enableMessageExpirationOnActiveDurableSubs; private final AtomicBoolean active = new AtomicBoolean(); private final AtomicLong offlineTimestamp = new AtomicLong(-1); private final HashSet ackedAndPrepared = new HashSet(); @@ -69,6 +70,7 @@ this.pending.setSystemUsage(usageManager); this.pending.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark()); this.keepDurableSubsActive = keepDurableSubsActive; + this.enableMessageExpirationOnActiveDurableSubs = broker.getBrokerService().isEnableMessageExpirationOnActiveDurableSubs(); subscriptionKey = new SubscriptionKey(context.getClientId(), info.getSubscriptionName()); } @@ -429,4 +431,8 @@ public boolean isKeepDurableSubsActive() { return keepDurableSubsActive; } + + public boolean isEnableMessageExpirationOnActiveDurableSubs() { + return enableMessageExpirationOnActiveDurableSubs; + } } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/UniquePropertyMessageEvictionStrategy.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/UniquePropertyMessageEvictionStrategy.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/UniquePropertyMessageEvictionStrategy.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/policy/UniquePropertyMessageEvictionStrategy.java 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; - +import java.util.List; /** * An eviction strategy which evicts the oldest message within messages with the same property value @@ -45,12 +45,10 @@ @Override public MessageReference[] evictMessages(LinkedList messages) throws IOException { - MessageReference oldest = (MessageReference)messages.getFirst(); - HashMap pivots = new HashMap(); - Iterator iter = messages.iterator(); + List messageReferences = new LinkedList<>(messages); + HashMap pivots = new HashMap<>(); - for (int i = 0; iter.hasNext(); i++) { - MessageReference reference = (MessageReference) iter.next(); + for (MessageReference reference : messageReferences) { if (propertyName != null && reference.getMessage().getProperty(propertyName) != null) { Object key = reference.getMessage().getProperty(propertyName); if (pivots.containsKey(key)) { @@ -64,16 +62,13 @@ } } - if (!pivots.isEmpty()) { - for (MessageReference ref : pivots.values()) { - messages.remove(ref); - } - - if (messages.size() != 0) { - return (MessageReference[])messages.toArray(new MessageReference[messages.size()]); - } + if (pivots.isEmpty() || pivots.values().size() == messageReferences.size()) { + return new MessageReference[]{(MessageReference) messages.removeFirst()}; + } else { + messages.removeIf(message -> !pivots.containsValue(message)); + messageReferences.removeAll(pivots.values()); + return messageReferences.toArray(new MessageReference[0]); } - return new MessageReference[] {oldest}; - } + } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java 2021-01-14 13:00:24.000000000 +0000 @@ -2093,7 +2093,7 @@ dropMessage(ref); if (gotToTheStore(ref.getMessage())) { LOG.debug("Duplicate message {} from cursor, removing from store", ref.getMessage()); - store.removeMessage(connectionContext, new MessageAck(ref.getMessage(), MessageAck.POSION_ACK_TYPE, 1)); + store.removeMessage(connectionContext, new MessageAck(ref.getMessage(), MessageAck.POISON_ACK_TYPE, 1)); } broker.getRoot().sendToDeadLetterQueue(connectionContext, ref.getMessage(), null, new Throwable("duplicate paged in from cursor for " + destination)); } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/Topic.java 2021-01-14 13:00:24.000000000 +0000 @@ -686,7 +686,7 @@ final ConnectionContext connectionContext = createConnectionContext(); for (Message message : toExpire) { for (DurableTopicSubscription sub : durableSubscribers.values()) { - if (!sub.isActive()) { + if (!sub.isActive() || sub.isEnableMessageExpirationOnActiveDurableSubs()) { message.setRegionDestination(this); messageExpired(connectionContext, sub, message); } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java 2021-01-14 13:00:24.000000000 +0000 @@ -116,7 +116,11 @@ if (info.getPrefetchSize() > 1 && matched.size() > info.getPrefetchSize()) { // Slow consumers should log and set their state as such. if (!isSlowConsumer()) { - LOG.warn("{}: has twice its prefetch limit pending, without an ack; it appears to be slow", toString()); + String remoteAddr = null; + if (context != null && context.getConnection() != null) { + remoteAddr = context.getConnection().getRemoteAddress(); + } + LOG.warn("{}: has twice its prefetch limit pending, without an ack; it appears to be slow{}", toString(), (remoteAddr != null) ? ": " + remoteAddr : ""); setSlowConsumer(true); for (Destination dest: destinations) { dest.slowConsumer(getContext(), this); @@ -133,7 +137,7 @@ return; } if (!warnedAboutWait) { - LOG.info("{}: Pending message cursor [{}] is full, temp usag ({}%) or memory usage ({}%) limit reached, blocking message add() pending the release of resources.", + LOG.info("{}: Pending message cursor [{}] is full, temp usage ({}%) or memory usage ({}%) limit reached, blocking message add() pending the release of resources.", new Object[]{ toString(), matched, diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestinationFilter.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestinationFilter.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestinationFilter.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestinationFilter.java 2021-01-14 13:00:24.000000000 +0000 @@ -41,12 +41,14 @@ private Collection forwardDestinations; private boolean forwardOnly; private boolean concurrentSend = false; + private boolean sendWhenNotMatched=false; - public CompositeDestinationFilter(Destination next, Collection forwardDestinations, boolean forwardOnly, boolean concurrentSend) { + public CompositeDestinationFilter(Destination next, Collection forwardDestinations, boolean forwardOnly,boolean sendWhenNotMatched, boolean concurrentSend) { super(next); this.forwardDestinations = forwardDestinations; this.forwardOnly = forwardOnly; this.concurrentSend = concurrentSend; + this.sendWhenNotMatched = sendWhenNotMatched; } @Override @@ -100,9 +102,17 @@ doForward(context, message, brokerService.getRegionBroker(), destination); } } - if (!forwardOnly) { - super.send(context, message); + if(sendWhenNotMatched) + { + if(matchingDestinations.size() <=0) { + super.send(context, message); + } + }else { + if (!forwardOnly) { + super.send(context, message); + } } + concurrent.await(); if (exceptionAtomicReference.get() != null) { throw exceptionAtomicReference.get(); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestination.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestination.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestination.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/CompositeDestination.java 2021-01-14 13:00:24.000000000 +0000 @@ -30,10 +30,11 @@ private Collection forwardTo; private boolean forwardOnly = true; private boolean concurrentSend = false; + private boolean sendWhenNotMatched = false; @Override public Destination intercept(Destination destination) { - return new CompositeDestinationFilter(destination, getForwardTo(), isForwardOnly(), isConcurrentSend()); + return new CompositeDestinationFilter(destination, getForwardTo(), isForwardOnly(),isSendWhenNotMatched(), isConcurrentSend()); } @Override @@ -192,4 +193,12 @@ return true; } + + public boolean isSendWhenNotMatched() { + return sendWhenNotMatched; + } + + public void setSendWhenNotMatched(boolean sendWhenNotMatched) { + this.sendWhenNotMatched = sendWhenNotMatched; + } } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/MirroredQueue.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/MirroredQueue.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/MirroredQueue.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/MirroredQueue.java 2021-01-14 13:00:24.000000000 +0000 @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; /** - * Creates Mirrored + * Creates Mirrored * Queue using a prefix and postfix to define the topic name on which to mirror the queue to. * * diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/package.html activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/package.html --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/package.html 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/package.html 2021-01-14 13:00:24.000000000 +0000 @@ -19,7 +19,7 @@ -Implementation classes for Virtual Destinations +Implementation classes for Virtual Destinations diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/SelectorAwareVirtualTopicInterceptor.java 2021-01-14 13:00:24.000000000 +0000 @@ -77,7 +77,7 @@ LOG.debug("No active consumer match found. Will try cache if configured..."); if (selectorCachePlugin != null) { - final Set selectors = selectorCachePlugin.getSelector(dest.getActiveMQDestination().getQualifiedName()); + final Set selectors = selectorCachePlugin.getSelectorsForDestination(dest.getActiveMQDestination().getQualifiedName()); if (selectors != null) { for (String selector : selectors) { try { diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopicInterceptor.java 2021-01-14 13:00:24.000000000 +0000 @@ -37,7 +37,7 @@ import javax.jms.ResourceAllocationException; /** - * A Destination which implements Virtual Topic + * A Destination which implements Virtual Topic */ public class VirtualTopicInterceptor extends DestinationFilter { diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopic.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopic.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopic.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/region/virtual/VirtualTopic.java 2021-01-14 13:00:24.000000000 +0000 @@ -28,7 +28,7 @@ import org.apache.activemq.filter.DestinationFilter; /** - * Creates Virtual + * Creates Virtual * Topics using a prefix and postfix. The virtual destination creates a * wildcard that is then used to look up all active queue subscriptions which * match. diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnector.java 2021-01-14 13:00:24.000000000 +0000 @@ -76,6 +76,7 @@ private int maximumProducersAllowedPerConnection = Integer.MAX_VALUE; private int maximumConsumersAllowedPerConnection = Integer.MAX_VALUE; private PublishedAddressPolicy publishedAddressPolicy = new PublishedAddressPolicy(); + private boolean allowLinkStealing = false; private boolean warnOnRemoteClose = false; LinkedList peerBrokers = new LinkedList(); @@ -125,6 +126,7 @@ rc.setMaximumConsumersAllowedPerConnection(getMaximumConsumersAllowedPerConnection()); rc.setMaximumProducersAllowedPerConnection(getMaximumProducersAllowedPerConnection()); rc.setPublishedAddressPolicy(getPublishedAddressPolicy()); + rc.setAllowLinkStealing(allowLinkStealing); rc.setWarnOnRemoteClose(isWarnOnRemoteClose()); return rc; } @@ -602,6 +604,10 @@ return server.isAllowLinkStealing(); } + public void setAllowLinkStealing(boolean allowLinkStealing) { + this.allowLinkStealing = allowLinkStealing; + } + public boolean isAuditNetworkProducers() { return auditNetworkProducers; } diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java 2021-01-14 13:00:24.000000000 +0000 @@ -1094,11 +1094,11 @@ if (messageDispatch != null) { LOG.warn("PoisonAck of {} on forwarding error: {}", messageDispatch.getMessage().getMessageId(), error); try { - MessageAck poisonAck = new MessageAck(messageDispatch, MessageAck.POSION_ACK_TYPE, 1); + MessageAck poisonAck = new MessageAck(messageDispatch, MessageAck.POISON_ACK_TYPE, 1); poisonAck.setPoisonCause(error); localBroker.oneway(poisonAck); } catch (IOException ioe) { - LOG.error("Failed to posion ack message following forward failure: ", ioe); + LOG.error("Failed to poison ack message following forward failure: ", ioe); } fireFailedForwardAdvisory(messageDispatch, error); } else { diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/plugin/SubQueueSelectorCacheBroker.java 2021-01-14 13:00:24.000000000 +0000 @@ -69,7 +69,7 @@ * The subscription's selector cache. We cache compiled expressions keyed * by the target destination. */ - private ConcurrentMap> subSelectorCache = new ConcurrentHashMap>(); + private ConcurrentMap> subSelectorCache = new ConcurrentHashMap<>(); private final File persistFile; private boolean singleSelectorPerDestination = false; @@ -249,13 +249,6 @@ } /** - * @return The JMS selector for the specified {@code destination} - */ - public Set getSelector(final String destination) { - return subSelectorCache.get(destination); - } - - /** * Persist the selector cache every {@code MAX_PERSIST_INTERVAL}ms. * * @see java.lang.Runnable#run() @@ -282,8 +275,11 @@ @SuppressWarnings("unchecked") public Set getSelectorsForDestination(String destinationName) { - if (subSelectorCache.containsKey(destinationName)) { - return new HashSet(subSelectorCache.get(destinationName)); + final Set cachedSelectors = subSelectorCache.get(destinationName); + if (cachedSelectors != null) { + synchronized(cachedSelectors) { + return new HashSet<>(cachedSelectors); + } } return Collections.EMPTY_SET; @@ -298,17 +294,13 @@ } public boolean deleteSelectorForDestination(String destinationName, String selector) { - if (subSelectorCache.containsKey(destinationName)) { - Set cachedSelectors = subSelectorCache.get(destinationName); - return cachedSelectors.remove(selector); - } - - return false; + final Set cachedSelectors = subSelectorCache.get(destinationName); + return cachedSelectors != null ? cachedSelectors.remove(selector) : false; } public boolean deleteAllSelectorsForDestination(String destinationName) { - if (subSelectorCache.containsKey(destinationName)) { - Set cachedSelectors = subSelectorCache.get(destinationName); + final Set cachedSelectors = subSelectorCache.get(destinationName); + if (cachedSelectors != null) { cachedSelectors.clear(); } return true; @@ -377,7 +369,10 @@ @Override protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { - if (!(desc.getName().equals("java.lang.String") || desc.getName().startsWith("java.util."))) { + if (!(desc.getName().startsWith("java.lang.") + || desc.getName().startsWith("com.thoughtworks.xstream") + || desc.getName().startsWith("java.util.") + || desc.getName().startsWith("org.apache.activemq."))) { throw new InvalidClassException("Unauthorized deserialization attempt", desc.getName()); } return super.resolveClass(desc); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/BooleanEditor.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/BooleanEditor.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/BooleanEditor.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/BooleanEditor.java 2021-01-14 13:00:24.000000000 +0000 @@ -35,9 +35,9 @@ } public void setAsText(String text) throws java.lang.IllegalArgumentException { - if (text.toLowerCase().equals("true")) { + if (text.equalsIgnoreCase("true")) { setValue(Boolean.TRUE); - } else if (text.toLowerCase().equals("false")) { + } else if (text.equalsIgnoreCase("false")) { setValue(Boolean.FALSE); } else { throw new java.lang.IllegalArgumentException(text); diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java 2021-01-14 13:00:24.000000000 +0000 @@ -17,8 +17,6 @@ package org.apache.activemq.util; import java.beans.PropertyEditorSupport; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Used by xbean to set integers. @@ -31,36 +29,7 @@ */ public class MemoryIntPropertyEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { - - Pattern p = Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$", Pattern.CASE_INSENSITIVE); - Matcher m = p.matcher(text); - if (m.matches()) { - setValue(Integer.valueOf(Integer.parseInt(m.group(1)))); - return; - } - - p = Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE); - m = p.matcher(text); - if (m.matches()) { - setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024)); - return; - } - - p = Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE); - m = p.matcher(text); - if (m.matches()) { - setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024 * 1024)); - return; - } - - p = Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE); - m = p.matcher(text); - if (m.matches()) { - setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024 * 1024 * 1024)); - return; - } - - throw new IllegalArgumentException("Could convert not to a memory size: " + text); + setValue(XBeanByteConverterUtil.convertToIntegerBytes(text)); } public String getAsText() { diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java 2021-01-14 13:00:24.000000000 +0000 @@ -17,8 +17,6 @@ package org.apache.activemq.util; import java.beans.PropertyEditorSupport; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * Used by xbean to set longs. @@ -31,36 +29,7 @@ */ public class MemoryPropertyEditor extends PropertyEditorSupport { public void setAsText(String text) throws IllegalArgumentException { - - Pattern p = Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$", Pattern.CASE_INSENSITIVE); - Matcher m = p.matcher(text); - if (m.matches()) { - setValue(Long.valueOf(Long.parseLong(m.group(1)))); - return; - } - - p = Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE); - m = p.matcher(text); - if (m.matches()) { - setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024)); - return; - } - - p = Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE); - m = p.matcher(text); - if (m.matches()) { - setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024)); - return; - } - - p = Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE); - m = p.matcher(text); - if (m.matches()) { - setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024 * 1024)); - return; - } - - throw new IllegalArgumentException("Could convert not to a memory size: " + text); + setValue(XBeanByteConverterUtil.convertToLongBytes(text)); } public String getAsText() { diff -Nru activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/XBeanByteConverterUtil.java activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/XBeanByteConverterUtil.java --- activemq-5.16.0/activemq-broker/src/main/java/org/apache/activemq/util/XBeanByteConverterUtil.java 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/main/java/org/apache/activemq/util/XBeanByteConverterUtil.java 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,66 @@ +/** + * 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.util; + +import java.io.File; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Converts string values like "20 Mb", "1024kb", and "1g" to long or int values in bytes. + */ +public final class XBeanByteConverterUtil { + + private static final Pattern[] BYTE_MATCHERS = new Pattern[] { + Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$", Pattern.CASE_INSENSITIVE), + Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE), + Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE), + Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE)}; + + private XBeanByteConverterUtil() { + // complete + } + + public static Long convertToLongBytes(String str) throws IllegalArgumentException { + for (int i = 0; i < BYTE_MATCHERS.length; i++) { + Matcher matcher = BYTE_MATCHERS[i].matcher(str); + if (matcher.matches()) { + long value = Long.parseLong(matcher.group(1)); + for (int j = 1; j <= i; j++) { + value *= 1024; + } + return Long.valueOf(value); + } + } + throw new IllegalArgumentException("Could not convert to a memory size: " + str); + } + + public static Integer convertToIntegerBytes(String str) throws IllegalArgumentException { + for (int i = 0; i < BYTE_MATCHERS.length; i++) { + Matcher matcher = BYTE_MATCHERS[i].matcher(str); + if (matcher.matches()) { + int value = Integer.parseInt(matcher.group(1)); + for (int j = 1; j <= i; j++) { + value *= 1024; + } + return Integer.valueOf(value); + } + } + throw new IllegalArgumentException("Could not convert to a memory size: " + str); + } + +} diff -Nru activemq-5.16.0/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java activemq-5.16.1/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java --- activemq-5.16.0/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java 2021-01-14 13:00:24.000000000 +0000 @@ -278,7 +278,7 @@ executor.execute(new B()); executor.shutdown(); - boolean finishedInTime = executor.awaitTermination(5, TimeUnit.MINUTES); + boolean finishedInTime = executor.awaitTermination(10, TimeUnit.MINUTES); LOG.info("Tested completion finished in time? -> {}", finishedInTime ? "YES" : "NO"); assertTrue("no exceptions", exceptions.isEmpty()); diff -Nru activemq-5.16.0/activemq-broker/src/test/java/org/apache/activemq/util/PropertyEditorTest.java activemq-5.16.1/activemq-broker/src/test/java/org/apache/activemq/util/PropertyEditorTest.java --- activemq-5.16.0/activemq-broker/src/test/java/org/apache/activemq/util/PropertyEditorTest.java 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-broker/src/test/java/org/apache/activemq/util/PropertyEditorTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,128 @@ +/** + * 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.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class PropertyEditorTest { + + @Test + public void testLongBytes() throws Exception { + MemoryPropertyEditor propertyEditor = new MemoryPropertyEditor(); + String expectedResult = String.valueOf(1000L); + + propertyEditor.setAsText("1000b"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000B"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testIntegerBytes() throws Exception { + MemoryIntPropertyEditor propertyEditor = new MemoryIntPropertyEditor(); + String expectedResult = String.valueOf(1000); + + propertyEditor.setAsText("1000b"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000B"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testLongKiloBytes() throws Exception { + MemoryPropertyEditor propertyEditor = new MemoryPropertyEditor(); + String expectedResult = String.valueOf(1024 * 1000L); + + propertyEditor.setAsText("1000kb"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000k"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000KB"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testIntegerKiloBytes() throws Exception { + MemoryIntPropertyEditor propertyEditor = new MemoryIntPropertyEditor(); + String expectedResult = String.valueOf(1024 * 1000); + + propertyEditor.setAsText("1000kb"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000k"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000KB"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testLongMegaBytes() throws Exception { + MemoryPropertyEditor propertyEditor = new MemoryPropertyEditor(); + String expectedResult = String.valueOf(1024 * 1024 * 1000L); + + propertyEditor.setAsText("1000mb"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000m"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000MB"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testIntegerMegaBytes() throws Exception { + MemoryIntPropertyEditor propertyEditor = new MemoryIntPropertyEditor(); + String expectedResult = String.valueOf(1024 * 1024 * 1000); + + propertyEditor.setAsText("1000mb"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000m"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000MB"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testLongGigaBytes() throws Exception { + MemoryPropertyEditor propertyEditor = new MemoryPropertyEditor(); + String expectedResult = String.valueOf(1024 * 1024 * 1024 * 1000L); + + propertyEditor.setAsText("1000gb"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000g"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000GB"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } + + @Test + public void testIntegerGigaBytes() throws Exception { + MemoryIntPropertyEditor propertyEditor = new MemoryIntPropertyEditor(); + String expectedResult = String.valueOf(1024 * 1024 * 1024 * 1000); + + propertyEditor.setAsText("1000gb"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000g"); + assertEquals(expectedResult, propertyEditor.getAsText()); + propertyEditor.setAsText("1000GB"); + assertEquals(expectedResult, propertyEditor.getAsText()); + } +} diff -Nru activemq-5.16.0/activemq-camel/pom.xml activemq-5.16.1/activemq-camel/pom.xml --- activemq-5.16.0/activemq-camel/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-camel/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-camel diff -Nru activemq-5.16.0/activemq-cf/pom.xml activemq-5.16.1/activemq-cf/pom.xml --- activemq-5.16.0/activemq-cf/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-cf/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -24,7 +24,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-cf diff -Nru activemq-5.16.0/activemq-client/pom.xml activemq-5.16.1/activemq-client/pom.xml --- activemq-5.16.0/activemq-client/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-client/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-client diff -Nru activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java --- activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java 2021-01-14 13:00:24.000000000 +0000 @@ -519,7 +519,7 @@ sendPullCommand(timeout); } else if (redeliveryExceeded(md)) { LOG.debug("{} received with excessive redelivered: {}", getConsumerId(), md); - posionAck(md, "Dispatch[" + md.getRedeliveryCounter() + "] to " + getConsumerId() + " exceeds redelivery policy limit:" + redeliveryPolicy); + poisonAck(md, "Dispatch[" + md.getRedeliveryCounter() + "] to " + getConsumerId() + " exceeds redelivery policy limit:" + redeliveryPolicy); if (timeout > 0) { timeout = Math.max(deadline - System.currentTimeMillis(), 0); } @@ -541,11 +541,11 @@ return isConsumerExpiryCheckEnabled() && dispatch.getMessage().isExpired(); } - private void posionAck(MessageDispatch md, String cause) throws JMSException { - MessageAck posionAck = new MessageAck(md, MessageAck.POSION_ACK_TYPE, 1); - posionAck.setFirstMessageId(md.getMessage().getMessageId()); - posionAck.setPoisonCause(new Throwable(cause)); - session.sendAck(posionAck); + private void poisonAck(MessageDispatch md, String cause) throws JMSException { + MessageAck poisonAck = new MessageAck(md, MessageAck.POISON_ACK_TYPE, 1); + poisonAck.setFirstMessageId(md.getMessage().getMessageId()); + poisonAck.setPoisonCause(new Throwable(cause)); + session.sendAck(poisonAck); } private boolean redeliveryExceeded(MessageDispatch md) { @@ -1271,7 +1271,7 @@ // DLQ. // Acknowledge the last message. - MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size()); + MessageAck ack = new MessageAck(lastMd, MessageAck.POISON_ACK_TYPE, deliveredMessages.size()); ack.setFirstMessageId(firstMsgId); ack.setPoisonCause(new Throwable("Delivery[" + lastMd.getMessage().getRedeliveryCounter() + "] exceeds redelivery policy limit:" + redeliveryPolicy + ", cause:" + lastMd.getRollbackCause(), lastMd.getRollbackCause())); @@ -1422,7 +1422,7 @@ if (this.info.isBrowser() || md.getDeliverySequenceId() != 0l || !session.connection.isDuplicate(this, md.getMessage())) { if (listener != null && unconsumedMessages.isRunning()) { if (redeliveryExceeded(md)) { - posionAck(md, "listener dispatch[" + md.getRedeliveryCounter() + "] to " + getConsumerId() + " exceeds redelivery policy limit:" + redeliveryPolicy); + poisonAck(md, "listener dispatch[" + md.getRedeliveryCounter() + "] to " + getConsumerId() + " exceeds redelivery policy limit:" + redeliveryPolicy); return; } ActiveMQMessage message = createActiveMQMessage(md); @@ -1483,7 +1483,7 @@ dispatch(md); } else { LOG.warn("{} suppressing duplicate delivery on connection, poison acking: {}", getConsumerId(), md); - posionAck(md, "Suppressing duplicate delivery on connection, consumer " + getConsumerId()); + poisonAck(md, "Suppressing duplicate delivery on connection, consumer " + getConsumerId()); } } } diff -Nru activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java --- activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/ActiveMQSession.java 2021-01-14 13:00:24.000000000 +0000 @@ -900,7 +900,7 @@ earlyAck.setFirstMessageId(message.getMessageId()); } else if (connection.isDuplicate(ActiveMQSession.this, message)) { LOG.debug("{} got duplicate: {}", this, message.getMessageId()); - earlyAck = new MessageAck(md, MessageAck.POSION_ACK_TYPE, 1); + earlyAck = new MessageAck(md, MessageAck.POISON_ACK_TYPE, 1); earlyAck.setFirstMessageId(md.getMessage().getMessageId()); earlyAck.setPoisonCause(new Throwable("Duplicate delivery to " + this)); } @@ -986,7 +986,7 @@ // sent to the // DLQ. // Acknowledge the last message. - MessageAck ack = new MessageAck(md, MessageAck.POSION_ACK_TYPE, 1); + MessageAck ack = new MessageAck(md, MessageAck.POISON_ACK_TYPE, 1); ack.setFirstMessageId(md.getMessage().getMessageId()); ack.setPoisonCause(new Throwable("Exceeded ra redelivery policy limit:" + redeliveryPolicy)); LOG.trace("Exceeded redelivery with count: {}, Ack: {}", redeliveryCounter, ack); diff -Nru activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/command/MessageAck.java activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/command/MessageAck.java --- activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/command/MessageAck.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/command/MessageAck.java 2021-01-14 13:00:24.000000000 +0000 @@ -44,7 +44,7 @@ * message was not processed and the message was considered a poison * message. */ - public static final byte POSION_ACK_TYPE = 1; + public static final byte POISON_ACK_TYPE = 1; /** * In case the client want's to explicitly let the broker know that a @@ -117,7 +117,7 @@ } public boolean isPoisonAck() { - return ackType == POSION_ACK_TYPE; + return ackType == POISON_ACK_TYPE; } public boolean isStandardAck() { diff -Nru activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java --- activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java 2021-01-14 13:00:24.000000000 +0000 @@ -345,20 +345,22 @@ private NetworkInterface findNetworkInterface() throws SocketException { Enumeration ifcs = NetworkInterface.getNetworkInterfaces(); List possibles = new ArrayList(); - while (ifcs.hasMoreElements()) { - NetworkInterface ni = ifcs.nextElement(); - try { - if (ni.supportsMulticast() - && ni.isUp()) { - for (InterfaceAddress ia : ni.getInterfaceAddresses()) { - if (ia != null && ia.getAddress() instanceof java.net.Inet4Address - && !ia.getAddress().isLoopbackAddress() - && (ni.getDisplayName()==null || !ni.getDisplayName().startsWith("vnic"))) { - possibles.add(ni); + if (ifcs != null) { + while (ifcs.hasMoreElements()) { + NetworkInterface ni = ifcs.nextElement(); + try { + if (ni.supportsMulticast() + && ni.isUp()) { + for (InterfaceAddress ia : ni.getInterfaceAddresses()) { + if (ia != null && ia.getAddress() instanceof java.net.Inet4Address + && !ia.getAddress().isLoopbackAddress() + && (ni.getDisplayName()==null || !ni.getDisplayName().startsWith("vnic"))) { + possibles.add(ni); + } } } - } - } catch (SocketException ignored) {} + } catch (SocketException ignored) {} + } } return possibles.isEmpty() ? null : possibles.get(possibles.size() - 1); } diff -Nru activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java --- activemq-5.16.0/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-client/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java 2021-01-14 13:00:24.000000000 +0000 @@ -40,7 +40,7 @@ private final ClassLoader inLoader; static { - serializablePackages = System.getProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper").split(","); + serializablePackages = System.getProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","java.lang,org.apache.activemq,org.fusesource.hawtbuf,com.thoughtworks.xstream.mapper").split(","); } public ClassLoadingAwareObjectInputStream(InputStream in) throws IOException { @@ -98,18 +98,21 @@ } private void checkSecurity(Class clazz) throws ClassNotFoundException { - if (!clazz.isPrimitive()) { - if (clazz.getPackage() != null && !trustAllPackages()) { - boolean found = false; - for (String packageName : getTrustedPackages()) { - if (clazz.getPackage().getName().equals(packageName) || clazz.getPackage().getName().startsWith(packageName + ".")) { - found = true; - break; - } - } - if (!found) { - 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."); - } + if (trustAllPackages() || clazz.isPrimitive()) { + return; + } + + boolean found = false; + Package thePackage = clazz.getPackage(); + if (thePackage != null) { + for (String trustedPackage : getTrustedPackages()) { + if (thePackage.getName().equals(trustedPackage) || thePackage.getName().startsWith(trustedPackage + ".")) { + found = true; + break; + } + } + if (!found) { + 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."); } } } diff -Nru activemq-5.16.0/activemq-console/pom.xml activemq-5.16.1/activemq-console/pom.xml --- activemq-5.16.0/activemq-console/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-console/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-console diff -Nru activemq-5.16.0/activemq-http/pom.xml activemq-5.16.1/activemq-http/pom.xml --- activemq-5.16.0/activemq-http/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-http/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-http diff -Nru activemq-5.16.0/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java activemq-5.16.1/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java --- activemq-5.16.0/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-http/src/main/java/org/apache/activemq/transport/http/HttpTunnelServlet.java 2021-01-14 13:00:24.000000000 +0000 @@ -161,21 +161,6 @@ return true; } - protected String readRequestBody(HttpServletRequest request) throws IOException { - StringBuffer buffer = new StringBuffer(); - BufferedReader reader = request.getReader(); - while (true) { - String line = reader.readLine(); - if (line == null) { - break; - } else { - buffer.append(line); - buffer.append("\n"); - } - } - return buffer.toString(); - } - protected BlockingQueueTransport getTransportChannel(HttpServletRequest request, HttpServletResponse response) throws IOException { String clientID = request.getHeader("clientID"); if (clientID == null) { diff -Nru activemq-5.16.0/activemq-http/src/main/java/org/apache/activemq/transport/util/HttpTransportUtils.java activemq-5.16.1/activemq-http/src/main/java/org/apache/activemq/transport/util/HttpTransportUtils.java --- activemq-5.16.0/activemq-http/src/main/java/org/apache/activemq/transport/util/HttpTransportUtils.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-http/src/main/java/org/apache/activemq/transport/util/HttpTransportUtils.java 2021-01-14 13:00:24.000000000 +0000 @@ -27,7 +27,7 @@ StringBuilder remoteAddress = new StringBuilder(); String scheme = request.getScheme(); - remoteAddress.append(scheme != null && scheme.toLowerCase().equals("https") ? "wss://" : "ws://"); + remoteAddress.append(scheme != null && scheme.equalsIgnoreCase("https") ? "wss://" : "ws://"); remoteAddress.append(request.getRemoteAddr()); remoteAddress.append(":"); remoteAddress.append(request.getRemotePort()); diff -Nru activemq-5.16.0/activemq-http/src/webapp/index.html activemq-5.16.1/activemq-http/src/webapp/index.html --- activemq-5.16.0/activemq-http/src/webapp/index.html 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-http/src/webapp/index.html 2021-01-14 13:00:24.000000000 +0000 @@ -26,7 +26,7 @@

This service allows you to tunnel ActiveMQ traffic through HTTP to work cleanly with firewalls. -For more information please see the ActiveMQ home page. +For more information please see the ActiveMQ home page.

diff -Nru activemq-5.16.0/activemq-itests-spring31/pom.xml activemq-5.16.1/activemq-itests-spring31/pom.xml --- activemq-5.16.0/activemq-itests-spring31/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-itests-spring31/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-itests-spring31 diff -Nru activemq-5.16.0/activemq-jaas/pom.xml activemq-5.16.1/activemq-jaas/pom.xml --- activemq-5.16.0/activemq-jaas/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jaas/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-jaas diff -Nru activemq-5.16.0/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java activemq-5.16.1/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java --- activemq-5.16.0/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jaas/src/main/java/org/apache/activemq/jaas/LDAPLoginModule.java 2021-01-14 13:00:24.000000000 +0000 @@ -440,6 +440,7 @@ if (log.isDebugEnabled()) { log.debug("Binding the user."); } + context.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple"); context.addToEnvironment(Context.SECURITY_PRINCIPAL, dn); context.addToEnvironment(Context.SECURITY_CREDENTIALS, password); try { @@ -465,7 +466,7 @@ } else { context.removeFromEnvironment(Context.SECURITY_CREDENTIALS); } - + context.addToEnvironment(Context.SECURITY_AUTHENTICATION, getLDAPPropertyValue(AUTHENTICATION)); return isValid; } diff -Nru activemq-5.16.0/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java activemq-5.16.1/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java --- activemq-5.16.0/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jaas/src/test/java/org/apache/activemq/jaas/LDAPLoginModuleTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -18,7 +18,6 @@ import org.apache.directory.server.core.integ.AbstractLdapTestUnit; import org.apache.directory.server.core.integ.FrameworkRunner; -import org.apache.directory.server.integ.ServerIntegrationUtils; import org.apache.directory.server.ldap.LdapServer; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; @@ -34,11 +33,11 @@ import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; import javax.security.auth.callback.*; +import javax.security.auth.login.FailedLoginException; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import java.io.IOException; -import java.net.URL; import java.util.HashSet; import java.util.Hashtable; @@ -47,7 +46,7 @@ import static org.junit.Assert.fail; @RunWith ( FrameworkRunner.class ) -@CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP", port=1024)}) +@CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP", port=1024)}, allowAnonymousAccess = true) @ApplyLdifFiles( "test.ldif" ) @@ -172,4 +171,47 @@ } + @Test + public void testAuthenticatedViaBindOnAnonConnection() throws Exception { + LoginContext context = new LoginContext("AnonBindCheckUserLDAPLogin", new CallbackHandler() { + @Override + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + if (callbacks[i] instanceof NameCallback) { + ((NameCallback) callbacks[i]).setName("first"); + } else if (callbacks[i] instanceof PasswordCallback) { + ((PasswordCallback) callbacks[i]).setPassword("wrongSecret".toCharArray()); + } else { + throw new UnsupportedCallbackException(callbacks[i]); + } + } + } + }); + try { + context.login(); + fail("Should have failed authenticating"); + } catch (FailedLoginException expected) { + } + } + + @Test + public void testAuthenticatedOkViaBindOnAnonConnection() throws Exception { + LoginContext context = new LoginContext("AnonBindCheckUserLDAPLogin", new CallbackHandler() { + @Override + public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { + for (int i = 0; i < callbacks.length; i++) { + if (callbacks[i] instanceof NameCallback) { + ((NameCallback) callbacks[i]).setName("first"); + } else if (callbacks[i] instanceof PasswordCallback) { + ((PasswordCallback) callbacks[i]).setPassword("secret".toCharArray()); + } else { + throw new UnsupportedCallbackException(callbacks[i]); + } + } + } + }); + context.login(); + context.logout(); + } + } diff -Nru activemq-5.16.0/activemq-jaas/src/test/resources/login.config activemq-5.16.1/activemq-jaas/src/test/resources/login.config --- activemq-5.16.0/activemq-jaas/src/test/resources/login.config 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jaas/src/test/resources/login.config 2021-01-14 13:00:24.000000000 +0000 @@ -105,6 +105,25 @@ ; }; +AnonBindCheckUserLDAPLogin { + org.apache.activemq.jaas.LDAPLoginModule required + debug=true + initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory + connectionURL="ldap://localhost:1024" + connectionUsername=none + connectionPassword=none + connectionProtocol=s + authentication=none + userBase="ou=system" + userSearchMatching="(uid={0})" + userSearchSubtree=false + roleBase="ou=system" + roleName=cn + roleSearchMatching="(member=uid={1},ou=system)" + roleSearchSubtree=false + ; +}; + ExpandedLDAPLogin { org.apache.activemq.jaas.LDAPLoginModule required debug=true diff -Nru activemq-5.16.0/activemq-jdbc-store/pom.xml activemq-5.16.1/activemq-jdbc-store/pom.xml --- activemq-5.16.0/activemq-jdbc-store/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jdbc-store/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-jdbc-store diff -Nru activemq-5.16.0/activemq-jms-pool/pom.xml activemq-5.16.1/activemq-jms-pool/pom.xml --- activemq-5.16.0/activemq-jms-pool/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jms-pool/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-jms-pool diff -Nru activemq-5.16.0/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/IntrospectionSupport.java activemq-5.16.1/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/IntrospectionSupport.java --- activemq-5.16.0/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/IntrospectionSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/IntrospectionSupport.java 2021-01-14 13:00:24.000000000 +0000 @@ -20,7 +20,9 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; + import javax.net.ssl.SSLServerSocket; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -97,7 +99,7 @@ return to.cast(value); } - if (boolean.class.isAssignableFrom(to) && value instanceof String) { + if ((boolean.class.isAssignableFrom(to) || Boolean.class.isAssignableFrom(to)) && value instanceof String) { return Boolean.valueOf((String)value); } diff -Nru activemq-5.16.0/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/package.html activemq-5.16.1/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/package.html --- activemq-5.16.0/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/package.html 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/package.html 2021-01-14 13:00:24.000000000 +0000 @@ -20,6 +20,6 @@ A JMS provider which pools Connection, Session and MessageProducer instances so it can be used with tools like -Spring's JmsTemplate. +Spring's JmsTemplate. diff -Nru activemq-5.16.0/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java activemq-5.16.1/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java --- activemq-5.16.0/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jms-pool/src/main/java/org/apache/activemq/jms/pool/XaPooledConnectionFactory.java 2021-01-14 13:00:24.000000000 +0000 @@ -43,7 +43,7 @@ private static final long serialVersionUID = -6545688026350913005L; private TransactionManager transactionManager; - private boolean tmFromJndi = false; + private Boolean tmFromJndi = false; private String tmJndiName = "java:/TransactionManager"; public TransactionManager getTransactionManager() { @@ -129,7 +129,7 @@ this.tmJndiName = tmJndiName; } - public boolean isTmFromJndi() { + public Boolean isTmFromJndi() { return tmFromJndi; } @@ -138,7 +138,7 @@ * * @param tmFromJndi */ - public void setTmFromJndi(boolean tmFromJndi) { + public void setTmFromJndi(Boolean tmFromJndi) { this.tmFromJndi = tmFromJndi; } } diff -Nru activemq-5.16.0/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/XAConnectionPoolTest.java activemq-5.16.1/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/XAConnectionPoolTest.java --- activemq-5.16.0/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/XAConnectionPoolTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/XAConnectionPoolTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -322,8 +322,8 @@ public void testBindableEnvOverrides() throws Exception { XaPooledConnectionFactory pcf = new XaPooledConnectionFactory(); assertTrue(pcf instanceof ObjectFactory); - Hashtable environment = new Hashtable(); - environment.put("tmFromJndi", String.valueOf(Boolean.FALSE)); + Hashtable environment = new Hashtable<>(); + environment.put("tmFromJndi", Boolean.FALSE); assertTrue(((ObjectFactory) pcf).getObjectInstance(null, null, null, environment) instanceof XaPooledConnectionFactory); assertFalse(pcf.isTmFromJndi()); pcf.stop(); diff -Nru activemq-5.16.0/activemq-kahadb-store/pom.xml activemq-5.16.1/activemq-kahadb-store/pom.xml --- activemq-5.16.0/activemq-kahadb-store/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-kahadb-store/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-kahadb-store diff -Nru activemq-5.16.0/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java activemq-5.16.1/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java --- activemq-5.16.0/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java 2021-01-14 13:00:24.000000000 +0000 @@ -4254,8 +4254,10 @@ @Override protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { - if (!(desc.getName().startsWith("java.lang.") || desc.getName().startsWith("java.util.") - || desc.getName().startsWith("org.apache.activemq."))) { + if (!(desc.getName().startsWith("java.lang.") + || desc.getName().startsWith("com.thoughtworks.xstream") + || desc.getName().startsWith("java.util.") + || desc.getName().startsWith("org.apache.activemq."))) { throw new InvalidClassException("Unauthorized deserialization attempt", desc.getName()); } return super.resolveClass(desc); diff -Nru activemq-5.16.0/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/scheduler/AMQ7086Test.java activemq-5.16.1/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/scheduler/AMQ7086Test.java --- activemq-5.16.0/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/scheduler/AMQ7086Test.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/scheduler/AMQ7086Test.java 2021-01-14 13:00:24.000000000 +0000 @@ -42,7 +42,7 @@ JobSchedulerStoreImpl jobSchedulerStore; KahaDBPersistenceAdapter kahaDBPersistenceAdapter; - @Test + @Test(timeout = 120000) public void testGcDoneAtStop() throws Exception { brokerService = createBroker(true); @@ -63,8 +63,14 @@ brokerService.stop(); + while (verifyFilesOnDisk(jobDir) < 1) { + Thread.sleep(100); + } assertTrue("Expected job store data files at least 1", verifyFilesOnDisk(jobDir) >= 1); - assertEquals("Expected kahadb data files", 1, verifyFilesOnDisk(kahaDir)); + while (verifyFilesOnDisk(kahaDir) < 1) { + Thread.sleep(100); + } + assertTrue("Expected kahadb data files at least 1", verifyFilesOnDisk(kahaDir) >= 1); } @Test diff -Nru activemq-5.16.0/activemq-karaf/pom.xml activemq-5.16.1/activemq-karaf/pom.xml --- activemq-5.16.0/activemq-karaf/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-karaf/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-karaf diff -Nru activemq-5.16.0/activemq-karaf/src/main/resources/features-core.xml activemq-5.16.1/activemq-karaf/src/main/resources/features-core.xml --- activemq-5.16.0/activemq-karaf/src/main/resources/features-core.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-karaf/src/main/resources/features-core.xml 2021-01-14 13:00:24.000000000 +0000 @@ -18,13 +18,12 @@ --> - + - - + mvn:org.apache.karaf.features/spring-legacy/[4,5)/xml/features - + spring shell-compat mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/1.1.1 @@ -33,27 +32,31 @@ mvn:org.apache.geronimo.specs/geronimo-j2ee-management_1.1_spec/1.0.1 mvn:org.jvnet.jaxb2_commons/jaxb2-basics-runtime/${jaxb-basics-version} mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/${jaxb-bundle-version} - mvn:org.apache.commons/commons-pool2/${commons-pool2-version} - mvn:commons-net/commons-net/${commons-net-version} - mvn:org.apache.zookeeper/zookeeper/${zookeeper-version} + mvn:org.apache.commons/commons-pool2/${commons-pool2-version} + mvn:commons-net/commons-net/${commons-net-version} + mvn:org.apache.zookeeper/zookeeper/${zookeeper-version} mvn:org.apache.activemq/activemq-osgi/${project.version} - + activemq-client scr mvn:org.apache.activemq/activemq-cf/${project.version} - + connector http activemq-client - mvn:org.apache.activemq/activemq-karaf/${project.version} + + shell + mvn:org.apache.activemq/activemq-karaf/${project.version} + + mvn:commons-io/commons-io/${commons-io-version} mvn:commons-collections/commons-collections/${commons-collections-version} - mvn:commons-lang/commons-lang/${commons-lang-version} + mvn:commons-lang/commons-lang/${commons-lang-version} mvn:commons-codec/commons-codec/1.9 mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.velocity/1.7_6 mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.2_1 @@ -70,4 +73,4 @@ mvn:com.fasterxml.jackson.core/jackson-annotations/${jackson-version} mvn:org.scala-lang/scala-library/${scala-version} - + diff -Nru activemq-5.16.0/activemq-karaf/src/main/resources/features.xml activemq-5.16.1/activemq-karaf/src/main/resources/features.xml --- activemq-5.16.0/activemq-karaf/src/main/resources/features.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-karaf/src/main/resources/features.xml 2021-01-14 13:00:24.000000000 +0000 @@ -18,26 +18,26 @@ --> - + mvn:org.apache.activemq/activemq-karaf/${project.version}/xml/features-core - + activemq mvn:org.apache.activemq/activemq-karaf/${project.version}/xml/activemq mvn:org.apache.activemq/activemq-karaf/${project.version}/cfg/activemq - + activemq mvn:org.apache.activemq/activemq-karaf/${project.version}/xml/activemq mvn:org.apache.activemq/activemq-karaf/${project.version}/cfg/activemq activemq-web-console - + activemq-client mvn:org.apache.activemq/activemq-camel/${project.version} camel-jms @@ -46,14 +46,14 @@ camel-blueprint - - war - eventadmin + + war + eventadmin mvn:org.apache.activemq/activemq-karaf/${project.version}/cfg/activemq-webconsole mvn:org.apache.activemq/activemq-web-console/${project.version}/war - + activemq mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.scripting-api-1.0/${servicemix.specs.version} mvn:org.apache.commons/commons-jexl/2.0.1 diff -Nru activemq-5.16.0/activemq-karaf-itest/pom.xml activemq-5.16.1/activemq-karaf-itest/pom.xml --- activemq-5.16.0/activemq-karaf-itest/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-karaf-itest/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-karaf-itest diff -Nru activemq-5.16.0/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java activemq-5.16.1/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java --- activemq-5.16.0/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -57,7 +57,7 @@ @ExamReactorStrategy(PerClass.class) public abstract class AbstractFeatureTest { - private static final String KARAF_MAJOR_VERSION = "4.2.8"; + private static final String KARAF_MAJOR_VERSION = "4.2.10"; public static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureTest.class); public static final long ASSERTION_TIMEOUT = 30000L; public static final String RESOURCE_BASE = "src/test/resources/org/apache/activemq/karaf/itest/"; @@ -120,6 +120,7 @@ } protected void assertBrokerStarted() throws Exception { + Thread.sleep(4000); withinReason(new Runnable() { public void run() { assertEquals("brokerName = amq-broker", executeCommand("activemq:list").trim()); @@ -155,8 +156,6 @@ logLevel(LogLevelOption.LogLevel.INFO), // editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg", "org.ops4j.pax.url.mvn.repositories", "https://repo1.maven.org/maven2@id=central"), editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"), - editConfigurationFileExtend("etc/org.apache.karaf.features.cfg", "featuresRepositories", - "mvn:org.apache.karaf.features/spring-legacy/" + karafVersion + "/xml/features"), // debugConfiguration("5005", true), features(activeMQUrl, features), // features(camelUrl) diff -Nru activemq-5.16.0/activemq-leveldb-store/pom.xml activemq-5.16.1/activemq-leveldb-store/pom.xml --- activemq-5.16.0/activemq-leveldb-store/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-leveldb-store/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-leveldb-store diff -Nru activemq-5.16.0/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java activemq-5.16.1/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java --- activemq-5.16.0/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/ElectingLevelDBStoreTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -222,7 +222,7 @@ } LOG.info("Imposing 11s I/O wait on Zookeeper connections, waiting 30s for quorum to be lost"); - this.connector.testHandle.setIOWaitMillis(11 * 1000, 30 * 1000); + this.connector.testHandle.setIOWaitMillis(11 * 1000, 60 * 1000); LOG.info("Confirming that the quorum has been lost"); for (ElectingLevelDBStore store: stores) { diff -Nru activemq-5.16.0/activemq-log4j-appender/pom.xml activemq-5.16.1/activemq-log4j-appender/pom.xml --- activemq-5.16.0/activemq-log4j-appender/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-log4j-appender/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-log4j-appender diff -Nru activemq-5.16.0/activemq-mqtt/pom.xml activemq-5.16.1/activemq-mqtt/pom.xml --- activemq-5.16.0/activemq-mqtt/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-mqtt/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-mqtt diff -Nru activemq-5.16.0/activemq-openwire-generator/pom.xml activemq-5.16.1/activemq-openwire-generator/pom.xml --- activemq-5.16.0/activemq-openwire-generator/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-openwire-generator/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-openwire-generator diff -Nru activemq-5.16.0/activemq-openwire-legacy/pom.xml activemq-5.16.1/activemq-openwire-legacy/pom.xml --- activemq-5.16.0/activemq-openwire-legacy/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-openwire-legacy/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-openwire-legacy diff -Nru activemq-5.16.0/activemq-osgi/pom.xml activemq-5.16.1/activemq-osgi/pom.xml --- activemq-5.16.0/activemq-osgi/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-osgi/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-osgi @@ -74,6 +74,7 @@ javax.management*, javax.transaction*;version="[1,3)", javax.naming*;resolution:=optional, + org.apache.commons.io*;resolution:=optional, org.apache.commons.pool*;resolution:=optional, org.apache.commons.net*;resolution:=optional, com.sun*;resolution:=optional, diff -Nru activemq-5.16.0/activemq-osgi/src/main/resources/META-INF/spring.schemas activemq-5.16.1/activemq-osgi/src/main/resources/META-INF/spring.schemas --- activemq-5.16.0/activemq-osgi/src/main/resources/META-INF/spring.schemas 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-osgi/src/main/resources/META-INF/spring.schemas 2021-01-14 13:00:24.000000000 +0000 @@ -68,6 +68,7 @@ http\://activemq.apache.org/schema/core/activemq-core-5.15.11.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-5.15.12.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-5.15.13.xsd=activemq.xsd +http\://activemq.apache.org/schema/core/activemq-core-5.15.14.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-5.16.0.xsd=activemq.xsd http\://camel.apache.org/schema/spring/camel-spring.xsd=camel-spring.xsd @@ -77,16 +78,28 @@ http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd http\://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd http\://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd -http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd +http\://www.springframework.org/schema/beans/spring-beans-4.0.xsd=org/springframework/beans/factory/xml/spring-beans-4.0.xsd +http\://www.springframework.org/schema/beans/spring-beans-4.1.xsd=org/springframework/beans/factory/xml/spring-beans-4.1.xsd +http\://www.springframework.org/schema/beans/spring-beans-4.2.xsd=org/springframework/beans/factory/xml/spring-beans-4.2.xsd +http\://www.springframework.org/schema/beans/spring-beans-4.3.xsd=org/springframework/beans/factory/xml/spring-beans-4.3.xsd +http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-4.3.xsd http\://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd http\://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd http\://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd http\://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd http\://www.springframework.org/schema/tool/spring-tool-3.2.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd -http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd +http\://www.springframework.org/schema/tool/spring-tool-4.0.xsd=org/springframework/beans/factory/xml/spring-tool-4.0.xsd +http\://www.springframework.org/schema/tool/spring-tool-4.1.xsd=org/springframework/beans/factory/xml/spring-tool-4.1.xsd +http\://www.springframework.org/schema/tool/spring-tool-4.2.xsd=org/springframework/beans/factory/xml/spring-tool-4.2.xsd +http\://www.springframework.org/schema/tool/spring-tool-4.3.xsd=org/springframework/beans/factory/xml/spring-tool-4.3.xsd +http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-4.3.xsd http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd http\://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd http\://www.springframework.org/schema/util/spring-util-3.2.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd -http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd +http\://www.springframework.org/schema/util/spring-util-4.0.xsd=org/springframework/beans/factory/xml/spring-util-4.0.xsd +http\://www.springframework.org/schema/util/spring-util-4.1.xsd=org/springframework/beans/factory/xml/spring-util-4.1.xsd +http\://www.springframework.org/schema/util/spring-util-4.2.xsd=org/springframework/beans/factory/xml/spring-util-4.2.xsd +http\://www.springframework.org/schema/util/spring-util-4.3.xsd=org/springframework/beans/factory/xml/spring-util-4.3.xsd +http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-4.3.xsd diff -Nru activemq-5.16.0/activemq-partition/pom.xml activemq-5.16.1/activemq-partition/pom.xml --- activemq-5.16.0/activemq-partition/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-partition/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-partition diff -Nru activemq-5.16.0/activemq-pool/pom.xml activemq-5.16.1/activemq-pool/pom.xml --- activemq-5.16.0/activemq-pool/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-pool/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-pool diff -Nru activemq-5.16.0/activemq-ra/pom.xml activemq-5.16.1/activemq-ra/pom.xml --- activemq-5.16.0/activemq-ra/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-ra/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-ra diff -Nru activemq-5.16.0/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java activemq-5.16.1/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java --- activemq-5.16.0/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java 2021-01-14 13:00:24.000000000 +0000 @@ -398,7 +398,7 @@ } /** - * Sets the XML + * Sets the XML * configuration file used to configure the ActiveMQ broker via Spring * if using embedded mode. * diff -Nru activemq-5.16.0/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java activemq-5.16.1/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java --- activemq-5.16.0/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-ra/src/main/java/org/apache/activemq/ra/ServerSessionImpl.java 2021-01-14 13:00:24.000000000 +0000 @@ -56,8 +56,7 @@ } - private int serverSessionId = getNextLogId(); - private final Logger log = LoggerFactory.getLogger(ServerSessionImpl.class.getName() + ":" + serverSessionId); + private final Logger log = LoggerFactory.getLogger(ServerSessionImpl.class); private ActiveMQSession session; private WorkManager workManager; @@ -105,7 +104,7 @@ } protected boolean isStale() { - return stale || !session.isRunning() || !session.isClosed(); + return stale || !session.isRunning(); } public MessageProducer getMessageProducer() throws JMSException { @@ -261,7 +260,7 @@ */ @Override public String toString() { - return "ServerSessionImpl:" + serverSessionId + "{" + session +"}"; + return "ServerSessionImpl:{" + session +"}"; } public void close() { diff -Nru activemq-5.16.0/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java activemq-5.16.1/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java --- activemq-5.16.0/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-ra/src/test/java/org/apache/activemq/ra/ServerSessionImplTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -57,6 +57,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @RunWith(JMock.class) @@ -433,4 +434,64 @@ } } + + + @Test + public void testSessionReusedByPool() throws Exception { + + final MessageEndpointFactory messageEndpointFactory = context.mock(MessageEndpointFactory.class); + final MessageResourceAdapter resourceAdapter = context.mock(MessageResourceAdapter.class); + final ActiveMQEndpointActivationKey key = context.mock(ActiveMQEndpointActivationKey.class); + messageEndpoint = context.mock(MessageEndpointProxy.class); + workManager = context.mock(WorkManager.class); + final MessageActivationSpec messageActivationSpec = context.mock(MessageActivationSpec.class); + final BootstrapContext bootstrapContext = context.mock(BootstrapContext.class); + context.checking(new Expectations() { + { + allowing(bootstrapContext).getWorkManager(); + will(returnValue(workManager)); + allowing(resourceAdapter).getBootstrapContext(); + will(returnValue(bootstrapContext)); + allowing(messageEndpointFactory).isDeliveryTransacted(with(any(Method.class))); + will(returnValue(Boolean.FALSE)); + allowing(key).getMessageEndpointFactory(); + will(returnValue(messageEndpointFactory)); + allowing(key).getActivationSpec(); + will(returnValue(messageActivationSpec)); + allowing(messageActivationSpec).isUseJndi(); + will(returnValue(Boolean.FALSE)); + allowing(messageActivationSpec).getDestinationType(); + will(returnValue("javax.jms.Queue")); + allowing(messageActivationSpec).getDestination(); + will(returnValue("Queue")); + allowing(messageActivationSpec).getAcknowledgeModeForSession(); + will(returnValue(1)); + allowing(messageActivationSpec).getMaxSessionsIntValue(); + will(returnValue(10)); + allowing(messageActivationSpec).getEnableBatchBooleanValue(); + will(returnValue(Boolean.FALSE)); + allowing(messageActivationSpec).isUseRAManagedTransactionEnabled(); + will(returnValue(Boolean.TRUE)); + allowing(messageEndpointFactory).createEndpoint(with(any(XAResource.class))); + will(returnValue(messageEndpoint)); + + allowing(workManager).scheduleWork((Work) with(Matchers.instanceOf(Work.class)), with(any(long.class)), with(any(ExecutionContext.class)), + with(any(WorkListener.class))); + allowing(messageEndpoint).release(); + } + }); + + endpointWorker = new ActiveMQEndpointWorker(resourceAdapter, key); + endpointWorker.setConnection(con); + + pool = new ServerSessionPoolImpl(endpointWorker, 2); + endpointWorker.start(); + + // the test! + ServerSessionImpl first = (ServerSessionImpl) pool.getServerSession(); + pool.returnToPool(first); + + ServerSessionImpl reused = (ServerSessionImpl) pool.getServerSession(); + assertEquals("got reuse", first, reused); + } } diff -Nru activemq-5.16.0/activemq-rar/pom.xml activemq-5.16.1/activemq-rar/pom.xml --- activemq-5.16.0/activemq-rar/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-rar/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-rar diff -Nru activemq-5.16.0/activemq-run/pom.xml activemq-5.16.1/activemq-run/pom.xml --- activemq-5.16.0/activemq-run/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-run/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-run diff -Nru activemq-5.16.0/activemq-runtime-config/pom.xml activemq-5.16.1/activemq-runtime-config/pom.xml --- activemq-5.16.0/activemq-runtime-config/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-runtime-config/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-runtime-config diff -Nru activemq-5.16.0/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/PropertiesPlaceHolderUtil.java activemq-5.16.1/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/PropertiesPlaceHolderUtil.java --- activemq-5.16.0/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/PropertiesPlaceHolderUtil.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/PropertiesPlaceHolderUtil.java 2021-01-14 13:00:24.000000000 +0000 @@ -18,6 +18,7 @@ import org.apache.activemq.broker.BrokerContext; import org.apache.activemq.spring.Utils; +import org.apache.activemq.util.XBeanByteConverterUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.FactoryBean; @@ -75,27 +76,13 @@ return replaceBytePostfix(str); } - static Pattern[] byteMatchers = new Pattern[] { - Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$", Pattern.CASE_INSENSITIVE), - Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE), - Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE), - Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE)}; - // xbean can Xb, Xkb, Xmb, Xg etc private String replaceBytePostfix(String str) { try { - for (int i=0; i< byteMatchers.length; i++) { - Matcher matcher = byteMatchers[i].matcher(str); - if (matcher.matches()) { - long value = Long.parseLong(matcher.group(1)); - for (int j=1; j<=i; j++) { - value *= 1024; - } - return String.valueOf(value); - } - } - } catch (NumberFormatException ignored) { - LOG.debug("nfe on: " + str, ignored); + Long value = XBeanByteConverterUtil.convertToLongBytes(str); + return String.valueOf(value); + } catch (IllegalArgumentException ignored) { + LOG.debug("iae on: " + str, ignored); } return str; } diff -Nru activemq-5.16.0/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java activemq-5.16.1/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java --- activemq-5.16.0/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/RuntimeConfigurationBroker.java 2021-01-14 13:00:24.000000000 +0000 @@ -233,7 +233,11 @@ ArrayList schemas = new ArrayList(); schemas.add(new StreamSource(getClass().getResource("/activemq.xsd").toExternalForm())); - schemas.add(new StreamSource(getClass().getResource("/org/springframework/beans/factory/xml/spring-beans-3.0.xsd").toExternalForm())); + if (getClass().getResource("/org/springframework/beans/factory/xml/spring-beans-3.0.xsd") != null) { + schemas.add(new StreamSource(getClass().getResource("/org/springframework/beans/factory/xml/spring-beans-3.0.xsd").toExternalForm())); + } else { + schemas.add(new StreamSource(getClass().getResource("/org/springframework/beans/factory/xml/spring-beans.xsd").toExternalForm())); + } schema = schemaFactory.newSchema(schemas.toArray(new Source[]{})); } return schema; diff -Nru activemq-5.16.0/activemq-shiro/pom.xml activemq-5.16.1/activemq-shiro/pom.xml --- activemq-5.16.0/activemq-shiro/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-shiro/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-shiro diff -Nru activemq-5.16.0/activemq-shiro/src/main/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermission.java activemq-5.16.1/activemq-shiro/src/main/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermission.java --- activemq-5.16.0/activemq-shiro/src/main/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermission.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-shiro/src/main/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermission.java 2021-01-14 13:00:24.000000000 +0000 @@ -59,18 +59,25 @@ } else { Set thisPart = getParts().get(i); - for (String token : thisPart) { - if (token.equals(WILDCARD_TOKEN)) { - continue; + // all tokens from otherPart must pass at least one token from thisPart + for (String otherToken : otherPart) { + if (!caseSensitive) { + otherToken = otherToken.toLowerCase(); } - for (String otherToken : otherPart) { - if (!caseSensitive) { - otherToken = otherToken.toLowerCase(); + boolean otherIsMatched = false; + for (String token : thisPart) { + if (token.equals(WILDCARD_TOKEN)) { + otherIsMatched = true; + break; } - if (!matches(token, otherToken)) { - return false; + if (matches(token, otherToken)) { + otherIsMatched = true; + break; } - } + } + if (!otherIsMatched) { + return false; + } } i++; } diff -Nru activemq-5.16.0/activemq-shiro/src/test/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermissionTest.java activemq-5.16.1/activemq-shiro/src/test/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermissionTest.java --- activemq-5.16.0/activemq-shiro/src/test/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermissionTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-shiro/src/test/java/org/apache/activemq/shiro/authz/ActiveMQWildcardPermissionTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -117,6 +117,10 @@ assertNoMatch("*:ActiveMQ*", "topic:TEST:*"); assertMatch("topic:ActiveMQ.Advisory*", "topic:ActiveMQ.Advisory.Connection:create"); assertMatch("foo?ar", "foobar"); + + assertMatch("queue:*:read,write", "queue:testqueue:read"); + assertMatch("queue:*:read,write", "queue:test*:read,write"); + assertNoMatch("queue:*:read,write", "queue:*:read,write,delete"); } protected static void assertMatch(String pattern, String value) { diff -Nru activemq-5.16.0/activemq-spring/pom.xml activemq-5.16.1/activemq-spring/pom.xml --- activemq-5.16.0/activemq-spring/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-spring/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-spring diff -Nru activemq-5.16.0/activemq-spring/src/main/resources/META-INF/spring.schemas activemq-5.16.1/activemq-spring/src/main/resources/META-INF/spring.schemas --- activemq-5.16.0/activemq-spring/src/main/resources/META-INF/spring.schemas 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-spring/src/main/resources/META-INF/spring.schemas 2021-01-14 13:00:24.000000000 +0000 @@ -68,6 +68,7 @@ http\://activemq.apache.org/schema/core/activemq-core-5.15.11.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-5.15.12.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-5.15.13.xsd=activemq.xsd +http\://activemq.apache.org/schema/core/activemq-core-5.15.14.xsd=activemq.xsd http\://activemq.apache.org/schema/core/activemq-core-5.16.0.xsd=activemq.xsd http\://camel.apache.org/schema/osgi/camel-osgi.xsd=camel-osgi.xsd diff -Nru activemq-5.16.0/activemq-stomp/pom.xml activemq-5.16.1/activemq-stomp/pom.xml --- activemq-5.16.0/activemq-stomp/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-stomp/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-stomp diff -Nru activemq-5.16.0/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java activemq-5.16.1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java --- activemq-5.16.0/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java 2021-01-14 13:00:24.000000000 +0000 @@ -49,14 +49,21 @@ super(wireFormat, socket, null, null, null); } - - public StompNIOSSLTransport(WireFormat wireFormat, Socket socket, SSLEngine engine, InitBuffer initBuffer, ByteBuffer inputBuffer) throws IOException { super(wireFormat, socket, engine, initBuffer, inputBuffer); } @Override + public String getRemoteAddress() { + String remoteAddress = super.getRemoteAddress(); + if (remoteAddress == null) { + return remoteLocation.toString(); + } + return remoteAddress; + } + + @Override protected void initializeStreams() throws IOException { codec = new StompCodec(this); super.initializeStreams(); diff -Nru activemq-5.16.0/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java activemq-5.16.1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java --- activemq-5.16.0/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompSubscription.java 2021-01-14 13:00:24.000000000 +0000 @@ -238,7 +238,7 @@ MessageAck ack = new MessageAck(); ack.setDestination(consumerInfo.getDestination()); ack.setConsumerId(consumerInfo.getConsumerId()); - ack.setAckType(MessageAck.POSION_ACK_TYPE); + ack.setAckType(MessageAck.POISON_ACK_TYPE); ack.setMessageID(msgId); if (transactionId != null) { transactedMessages.add(ackEntry); diff -Nru activemq-5.16.0/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java activemq-5.16.1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java --- activemq-5.16.0/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-stomp/src/test/java/org/apache/activemq/transport/stomp/StompTestSupport.java 2021-01-14 13:00:24.000000000 +0000 @@ -119,6 +119,9 @@ } public void startBroker() throws Exception { + if (brokerService != null) { + stopBroker(); + } createBroker(true); XStreamBrokerContext context = new XStreamBrokerContext(); diff -Nru activemq-5.16.0/activemq-tooling/activemq-junit/pom.xml activemq-5.16.1/activemq-tooling/activemq-junit/pom.xml --- activemq-5.16.0/activemq-tooling/activemq-junit/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-tooling/activemq-junit/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -21,7 +21,7 @@ org.apache.activemq.tooling activemq-tooling - 5.16.0 + 5.16.1 activemq-junit diff -Nru activemq-5.16.0/activemq-tooling/activemq-maven-plugin/pom.xml activemq-5.16.1/activemq-tooling/activemq-maven-plugin/pom.xml --- activemq-5.16.0/activemq-tooling/activemq-maven-plugin/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-tooling/activemq-maven-plugin/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -21,7 +21,7 @@ org.apache.activemq.tooling activemq-tooling - 5.16.0 + 5.16.1 activemq-maven-plugin diff -Nru activemq-5.16.0/activemq-tooling/activemq-memtest-maven-plugin/pom.xml activemq-5.16.1/activemq-tooling/activemq-memtest-maven-plugin/pom.xml --- activemq-5.16.0/activemq-tooling/activemq-memtest-maven-plugin/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-tooling/activemq-memtest-maven-plugin/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq.tooling activemq-tooling - 5.16.0 + 5.16.1 activemq-memtest-maven-plugin diff -Nru activemq-5.16.0/activemq-tooling/activemq-perf-maven-plugin/pom.xml activemq-5.16.1/activemq-tooling/activemq-perf-maven-plugin/pom.xml --- activemq-5.16.0/activemq-tooling/activemq-perf-maven-plugin/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-tooling/activemq-perf-maven-plugin/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -21,7 +21,7 @@ org.apache.activemq.tooling activemq-tooling - 5.16.0 + 5.16.1 activemq-perf-maven-plugin diff -Nru activemq-5.16.0/activemq-tooling/pom.xml activemq-5.16.1/activemq-tooling/pom.xml --- activemq-5.16.0/activemq-tooling/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-tooling/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 org.apache.activemq.tooling diff -Nru activemq-5.16.0/activemq-unit-tests/pom.xml activemq-5.16.1/activemq-unit-tests/pom.xml --- activemq-5.16.0/activemq-unit-tests/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-unit-tests diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerBenchmark.java 2021-01-14 13:00:24.000000000 +0000 @@ -121,7 +121,7 @@ if (msg != null) { connection.send(createAck(consumerInfo, msg, counter, MessageAck.STANDARD_ACK_TYPE)); } else if (receiveCounter.get() < consumeCount) { - LOG.info("Consumer stall, waiting for message #" + receiveCounter.get() + 1); + LOG.info("Consumer stall, waiting for message #" + (receiveCounter.get() + 1)); } } diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanWithAuditLogTest.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanWithAuditLogTest.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanWithAuditLogTest.java 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/jmx/MBeanWithAuditLogTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,44 @@ +/** + * 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.broker.jmx; + + +/** + * A test case of the various MBeans in ActiveMQ with audit log turned on. + */ +public class MBeanWithAuditLogTest extends MBeanTest { + + static final String requiredAuditValue = "all"; + static final String auditKey = "org.apache.activemq.audit"; + static final String initialAuditValue = System.getProperty("org.apache.activemq.audit"); + + @Override + protected void setUp() throws Exception { + System.setProperty(auditKey, requiredAuditValue); + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + if (initialAuditValue == null) { + System.clearProperty(auditKey); + } else { + System.setProperty(auditKey, initialAuditValue); + } + super.tearDown(); + } +} diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/UniquePropertyMessageEvictionStrategyTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -18,11 +18,13 @@ package org.apache.activemq.broker.region; import org.apache.activemq.EmbeddedBrokerTestSupport; +import org.apache.activemq.TestSupport; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.region.policy.ConstantPendingMessageLimitStrategy; import org.apache.activemq.broker.region.policy.PolicyEntry; import org.apache.activemq.broker.region.policy.PolicyMap; import org.apache.activemq.broker.region.policy.UniquePropertyMessageEvictionStrategy; +import org.apache.activemq.command.ActiveMQDestination; import javax.jms.*; import java.util.ArrayList; @@ -30,8 +32,6 @@ public class UniquePropertyMessageEvictionStrategyTest extends EmbeddedBrokerTestSupport { - - @Override protected BrokerService createBroker() throws Exception { BrokerService broker = super.createBroker(); @@ -80,8 +80,7 @@ Thread.sleep(100); } } - - + for (int i = 0; i < 11; i++) { javax.jms.Message msg = consumer.receive(1000); assertNotNull(msg); @@ -100,6 +99,7 @@ javax.jms.Message msg = consumer.receive(1000); assertNull(msg); + assertEquals("usage goes to 0", 0, TestSupport.getDestination(broker, ActiveMQDestination.transform(destination)).getMemoryUsage().getUsage()); } } diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/scheduler/memory/InMemoryJobSchedulerTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -16,21 +16,274 @@ */ package org.apache.activemq.broker.scheduler.memory; -import org.apache.activemq.broker.scheduler.JobSchedulerStore; -import org.apache.activemq.broker.scheduler.JobSchedulerTest; +import org.apache.activemq.broker.scheduler.*; +import org.apache.activemq.util.ByteSequence; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.Calendar; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * In-Memory store based variation of the JobSchedulerTest */ -public class InMemoryJobSchedulerTest extends JobSchedulerTest { +public class InMemoryJobSchedulerTest { + + private static final Logger LOG = LoggerFactory.getLogger(JobSchedulerTest.class); + + private JobSchedulerStore store; + private JobScheduler scheduler; + + @Test(timeout = 60000) + public void testAddLongStringByteSequence() throws Exception { + final int COUNT = 10; + final CountDownLatch latch = new CountDownLatch(COUNT); + scheduler.addListener(new JobListener() { + @Override + public void scheduledJob(String id, ByteSequence job) { + latch.countDown(); + } + + }); + for (int i = 0; i < COUNT; i++) { + String test = new String("test" + i); + scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), 1000); + } + latch.await(5, TimeUnit.SECONDS); + assertEquals(0, latch.getCount()); + } - @Override + @Test(timeout = 60000) + public void testAddCronAndByteSequence() throws Exception { + + final CountDownLatch latch = new CountDownLatch(1); + scheduler.addListener(new JobListener() { + @Override + public void scheduledJob(String id, ByteSequence job) { + latch.countDown(); + } + }); + + Calendar current = Calendar.getInstance(); + current.add(Calendar.MINUTE, 1); + int minutes = current.get(Calendar.MINUTE); + int hour = current.get(Calendar.HOUR_OF_DAY); + int day = current.get(Calendar.DAY_OF_WEEK) - 1; + + String cronTab = String.format("%d %d * * %d", minutes, hour, day); + + String str = new String("test1"); + scheduler.schedule("id:1", new ByteSequence(str.getBytes()), cronTab, 0, 0, 0); + + // need a little slack so go over 60 seconds + assertTrue(latch.await(70, TimeUnit.SECONDS)); + assertEquals(0, latch.getCount()); + } + + @Test(timeout = 60000) + public void testAddLongLongIntStringByteSequence() throws Exception { + final int COUNT = 10; + final CountDownLatch latch = new CountDownLatch(COUNT); + scheduler.addListener(new JobListener() { + @Override + public void scheduledJob(String id, ByteSequence job) { + latch.countDown(); + } + }); + long time = 2000; + for (int i = 0; i < COUNT; i++) { + String test = new String("test" + i); + scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), "", time, 10, -1); + } + assertTrue(latch.getCount() == COUNT); + latch.await(3000, TimeUnit.SECONDS); + assertTrue(latch.getCount() == 0); + } + + @Test(timeout = 60000) + @Ignore public void testAddStopThenDeliver() throws Exception { - // In Memory store that's stopped doesn't retain the jobs. + final int COUNT = 10; + final CountDownLatch latch = new CountDownLatch(COUNT); + long time = 2000; + for (int i = 0; i < COUNT; i++) { + String test = new String("test" + i); + scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), "", time, 1000, -1); + } + File directory = store.getDirectory(); + tearDown(); + setUp(); + scheduler.addListener(new JobListener() { + @Override + public void scheduledJob(String id, ByteSequence job) { + latch.countDown(); + } + }); + assertTrue(latch.getCount() == COUNT); + latch.await(3000, TimeUnit.SECONDS); + assertTrue(latch.getCount() == 0); + } + + @Test(timeout = 60000) + public void testRemoveLong() throws Exception { + final int COUNT = 10; + + long time = 60000; + for (int i = 0; i < COUNT; i++) { + String str = new String("test" + i); + scheduler.schedule("id" + i, new ByteSequence(str.getBytes()), "", time, 1000, -1); + } + + int size = scheduler.getAllJobs().size(); + assertEquals(size, COUNT); + + long removeTime = scheduler.getNextScheduleTime(); + scheduler.remove(removeTime); + + // If all jobs are not started within the same second we need to call remove again + if (size != 0) { + removeTime = scheduler.getNextScheduleTime(); + scheduler.remove(removeTime); + } + + size = scheduler.getAllJobs().size(); + assertEquals(0, size); + } + + @Test(timeout = 60000) + public void testRemoveString() throws Exception { + final int COUNT = 10; + final String test = "TESTREMOVE"; + long time = 20000; + + for (int i = 0; i < COUNT; i++) { + String str = new String("test" + i); + scheduler.schedule("id" + i, new ByteSequence(str.getBytes()), "", time, 1000, -1); + if (i == COUNT / 2) { + scheduler.schedule(test, new ByteSequence(test.getBytes()), "", time, 1000, -1); + } + } + + int size = scheduler.getAllJobs().size(); + assertEquals(size, COUNT + 1); + scheduler.remove(test); + size = scheduler.getAllJobs().size(); + assertEquals(size, COUNT); + } + + @Test(timeout = 60000) + public void testGetExecutionCount() throws Exception { + final String jobId = "Job-1"; + long time = 10000; + final CountDownLatch done = new CountDownLatch(10); + + String str = new String("test"); + scheduler.schedule(jobId, new ByteSequence(str.getBytes()), "", time, 1000, 10); + + int size = scheduler.getAllJobs().size(); + assertEquals(size, 1); + + scheduler.addListener(new JobListener() { + @Override + public void scheduledJob(String id, ByteSequence job) { + LOG.info("Job exectued: {}", 11 - done.getCount()); + done.countDown(); + } + }); + + List jobs = scheduler.getNextScheduleJobs(); + assertEquals(1, jobs.size()); + Job job = jobs.get(0); + assertEquals(jobId, job.getJobId()); + assertEquals(0, job.getExecutionCount()); + assertTrue("Should have fired ten times.", done.await(60, TimeUnit.SECONDS)); + // The job is not updated on the last firing as it is removed from the store following + // it's last execution so the count will always be one less than the max firings. + assertTrue(job.getExecutionCount() >= 9); + } + + @Test(timeout = 60000) + public void testgetAllJobs() throws Exception { + final int COUNT = 10; + final String ID = "id:"; + long time = 20000; + + for (int i = 0; i < COUNT; i++) { + String str = new String("test" + i); + scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", time, 10 + i, -1); + } + + List list = scheduler.getAllJobs(); + + assertEquals(list.size(), COUNT); + int count = 0; + for (Job job : list) { + assertEquals(job.getJobId(), ID + count); + count++; + } + } + + @Test(timeout = 60000) + public void testgetAllJobsInRange() throws Exception { + final int COUNT = 10; + final String ID = "id:"; + long start = 10000; + + for (int i = 0; i < COUNT; i++) { + String str = new String("test" + i); + scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", start + (i * 1000), 10000 + i, 0); + } + + start = System.currentTimeMillis(); + long finish = start + 12000 + (COUNT * 1000); + List list = scheduler.getAllJobs(start, finish); + + assertEquals(COUNT, list.size()); + int count = 0; + for (Job job : list) { + assertEquals(job.getJobId(), ID + count); + count++; + } + } + + @Test(timeout = 60000) + public void testRemoveAllJobsInRange() throws Exception { + final int COUNT = 10; + final String ID = "id:"; + long start = 10000; + + for (int i = 0; i < COUNT; i++) { + String str = new String("test" + i); + scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", start + (i * 1000), 10000 + i, 0); + } + start = System.currentTimeMillis(); + long finish = start + 12000 + (COUNT * 1000); + scheduler.removeAllJobs(start, finish); + + assertTrue(scheduler.getAllJobs().isEmpty()); + } + + @Before + public void setUp() throws Exception { + store = new InMemoryJobSchedulerStore(); + store.start(); + scheduler = store.getJobScheduler("test"); + scheduler.startDispatching(); } - @Override - protected JobSchedulerStore createJobSchedulerStore() throws Exception { - return new InMemoryJobSchedulerStore(); + @After + public void tearDown() throws Exception { + scheduler.stopDispatching(); + store.stop(); } } diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeDestinationSendWhenNotMatchedTest.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeDestinationSendWhenNotMatchedTest.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeDestinationSendWhenNotMatchedTest.java 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/broker/virtual/CompositeDestinationSendWhenNotMatchedTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,533 @@ +/** + * 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.broker.virtual; + +import java.util.ArrayList; + +import javax.jms.Connection; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import org.apache.activemq.EmbeddedBrokerTestSupport; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.region.DestinationInterceptor; +import org.apache.activemq.broker.region.virtual.CompositeQueue; +import org.apache.activemq.broker.region.virtual.FilteredDestination; +import org.apache.activemq.broker.region.virtual.VirtualDestination; +import org.apache.activemq.broker.region.virtual.VirtualDestinationInterceptor; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.spring.ConsumerBean; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CompositeDestinationSendWhenNotMatchedTest extends EmbeddedBrokerTestSupport { + + private static final Logger LOG = LoggerFactory.getLogger(CompositeQueueTest.class); + + protected int total = 10; + protected Connection connection; + + + @Test + public void testSendWhenNotMatched() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + // messageList1.waitForMessagesToArrive(0); + // messageList2.waitForMessagesToArrive(1); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.B"); + Destination destination1 =new ActiveMQQueue("A.B"); + Destination destination2 = new ActiveMQQueue("A.C"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "tet13")); + + messageList1.assertMessagesArrived(1); + messageList2.assertMessagesArrived(0); + } + + @Test + public void testSendWhenMatched() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + // messageList1.waitForMessagesToArrive(0); + // messageList2.waitForMessagesToArrive(1); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.B"); + Destination destination1 =new ActiveMQQueue("A.B"); + Destination destination2 = new ActiveMQQueue("A.C"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "test13")); + + messageList2.assertMessagesArrived(1); + messageList1.assertMessagesArrived(0); + + } + @Test + public void testForwardOnlyFalseSendWhenMatchedTrue1() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.D"); + Destination destination1 =new ActiveMQQueue("A.D"); + Destination destination2 = new ActiveMQQueue("A.E"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "tes13")); + + messageList1.assertMessagesArrived(1); + messageList2.assertMessagesArrived(0); + + } + + public void testForwardOnlyFalseSendWhenMatchedTrue2() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.D"); + Destination destination1 =new ActiveMQQueue("A.D"); + Destination destination2 = new ActiveMQQueue("A.E"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "test13")); + Thread.sleep(1*1000); + messageList2.assertMessagesArrived(1); + messageList1.assertMessagesArrived(0); + + } + @Test + public void testForwardOnlyFalseBackwardCompatability1() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.X"); + Destination destination1 =new ActiveMQQueue("A.X"); + Destination destination2 = new ActiveMQQueue("A.Y"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "test13")); + + messageList2.assertMessagesArrived(1); + messageList1.assertMessagesArrived(1); + + } + @Test + public void testForwardOnlyFalseBackwardCompatability2() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.X"); + Destination destination1 =new ActiveMQQueue("A.X"); + Destination destination2 = new ActiveMQQueue("A.Y"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "tet13")); + + + messageList1.assertMessagesArrived(1); + messageList2.assertMessagesArrived(0); + + } + + @Test + public void testForwardOnlyTrueBackwardCompatability1() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.W"); + Destination destination1 =new ActiveMQQueue("A.W"); + Destination destination2 = new ActiveMQQueue("A.V"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "test13")); + + messageList2.assertMessagesArrived(1); + messageList1.assertMessagesArrived(0); + + } + @Test + public void testForwardOnlyTrueBackwardCompatability2() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("A.W"); + Destination destination1 =new ActiveMQQueue("A.W"); + Destination destination2 = new ActiveMQQueue("A.V"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "tet13")); + Thread.sleep(2*1000); + messageList1.assertMessagesArrived(0); + messageList2.assertMessagesArrived(0); + + } + + @Test + public void testForwardOnlySendWhenNotMatchedSetToFalse() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + // messageList1.waitForMessagesToArrive(0); + // messageList2.waitForMessagesToArrive(1); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("X.Y"); + Destination destination1 = new ActiveMQQueue("X.Y"); + Destination destination2 = new ActiveMQQueue("X.Z"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "tet13")); + messageList2.assertMessagesArrived(1); + messageList1.assertMessagesArrived(0); + + } + @Test + public void testForwardOnlyFalseSendWhenNotMatchedSetToFalse() throws Exception { + if (connection == null) { + connection = createConnection(); + } + connection.start(); + + ConsumerBean messageList1 = new ConsumerBean(); + ConsumerBean messageList2 = new ConsumerBean(); + messageList1.setVerbose(true); + messageList2.setVerbose(true); + // messageList1.waitForMessagesToArrive(0); + // messageList2.waitForMessagesToArrive(1); + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Destination producerDestination = new ActiveMQQueue("R.S"); + Destination destination1 = new ActiveMQQueue("R.S"); + Destination destination2 = new ActiveMQQueue("R.T"); + + LOG.info("Sending to: " + producerDestination); + LOG.info("Consuming from: " + destination1 + " and " + destination2); + + MessageConsumer c1 = session.createConsumer(destination1); + MessageConsumer c2 = session.createConsumer(destination2); + + c1.setMessageListener(messageList1); + c2.setMessageListener(messageList2); + + // create topic producer + MessageProducer producer = session.createProducer(producerDestination); + assertNotNull(producer); + + producer.send(createMessage(session, "tet13")); + messageList1.assertMessagesArrived(1); + messageList2.assertMessagesArrived(1); + } + + protected Destination getConsumer1Dsetination() { + return new ActiveMQQueue("A.B"); + } + + protected Destination getConsumer2Dsetination() { + return new ActiveMQQueue("A.C"); + } + + protected Destination getProducerDestination() { + return new ActiveMQQueue("A.B"); + } + + protected TextMessage createMessage(Session session, String testid) throws JMSException { + TextMessage textMessage = session.createTextMessage("testMessage"); + textMessage.setStringProperty("testid", testid); + return textMessage; + } + + protected BrokerService createBroker() throws Exception { + BrokerService answer = new BrokerService(); + answer.setPersistent(isPersistent()); + answer.getManagementContext().setCreateConnector(false); + answer.addConnector(bindAddress); + /* + * + * + * + * + * + */ + /* + * SendWhenNotMatched = true A message will be always forwarded to if not matched to filtered destination + * ForwardOnly setting has no impact + */ + + CompositeQueue compositeQueue = new CompositeQueue(); + compositeQueue.setName("A.B"); + compositeQueue.setForwardOnly(true); // By default it is true + compositeQueue.setSendWhenNotMatched(true);// By default it is false + FilteredDestination filteredQueue = new FilteredDestination(); + filteredQueue.setQueue("A.C"); + filteredQueue.setSelector("testid LIKE 'test%'"); + final ArrayList forwardDestinations = new ArrayList(); + forwardDestinations.add(filteredQueue); + compositeQueue.setForwardTo(forwardDestinations); + + + CompositeQueue compositeQueue0 = new CompositeQueue(); + compositeQueue0.setName("A.D"); + compositeQueue0.setForwardOnly(false); // By default it is true + compositeQueue0.setSendWhenNotMatched(true);// By default it is false + FilteredDestination filteredQueue0 = new FilteredDestination(); + filteredQueue0.setQueue("A.E"); + filteredQueue0.setSelector("testid LIKE 'test%'"); + final ArrayList forwardDestinations0 = new ArrayList(); + forwardDestinations0.add(filteredQueue0); + compositeQueue0.setForwardTo(forwardDestinations0); + + //Back compatibility test 1 + CompositeQueue compositeQueue01 = new CompositeQueue(); + compositeQueue01.setName("A.X"); + compositeQueue01.setForwardOnly(false); // By default it is true + //compositeQueue01.setSendWhenNotMatched(false);// By default it is false + FilteredDestination filteredQueue01 = new FilteredDestination(); + filteredQueue01.setQueue("A.Y"); + filteredQueue01.setSelector("testid LIKE 'test%'"); + final ArrayList forwardDestinations01 = new ArrayList(); + forwardDestinations01.add(filteredQueue01); + compositeQueue01.setForwardTo(forwardDestinations01); + + //Back compatibility test 2 + CompositeQueue compositeQueue02 = new CompositeQueue(); + compositeQueue02.setName("A.W"); + //compositeQueue02.setForwardOnly(true); // By default it is true + //compositeQueue01.setSendWhenNotMatched(false);// By default it is false + FilteredDestination filteredQueue02 = new FilteredDestination(); + filteredQueue02.setQueue("A.V"); + filteredQueue02.setSelector("testid LIKE 'test%'"); + final ArrayList forwardDestinations02 = new ArrayList(); + forwardDestinations02.add(filteredQueue02); + compositeQueue02.setForwardTo(forwardDestinations02); + + CompositeQueue compositeQueue1 = new CompositeQueue(); + compositeQueue1.setName("X.Y"); + compositeQueue1.setForwardOnly(true); // By default it is true + ActiveMQQueue forwardQueue1 =new ActiveMQQueue("X.Z"); + final ArrayList forwardDestinations1 = new ArrayList(); + forwardDestinations1.add(forwardQueue1); + compositeQueue1.setForwardTo(forwardDestinations1); + + + CompositeQueue compositeQueue2 = new CompositeQueue(); + compositeQueue2.setName("R.S"); + compositeQueue2.setForwardOnly(false); + ActiveMQQueue forwardQueue2 =new ActiveMQQueue("R.T"); + final ArrayList forwardDestinations2 = new ArrayList(); + forwardDestinations2.add(forwardQueue2); + compositeQueue2.setForwardTo(forwardDestinations2); + + VirtualDestinationInterceptor interceptor = new VirtualDestinationInterceptor(); + interceptor.setVirtualDestinations(new VirtualDestination[] { compositeQueue,compositeQueue0,compositeQueue01,compositeQueue02,compositeQueue1,compositeQueue2 }); + answer.setDestinationInterceptors(new DestinationInterceptor[] { interceptor }); + return answer; + } +} diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7118Test.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7118Test.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7118Test.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ7118Test.java 2021-01-14 13:00:24.000000000 +0000 @@ -185,12 +185,18 @@ if(doCheckpoint) { LOG.info("Initiating checkpointUpdate "+ ++checkpointIndex + " ..."); broker.getPersistenceAdapter().checkpoint(true); - TimeUnit.SECONDS.sleep(2); + TimeUnit.SECONDS.sleep(4); LOG.info("Checkpoint complete."); } File files[] = dbfiles.listFiles(lff); Arrays.sort(files, new DBFileComparator() ); logfiles(files); + + while (files.length != expectedCount) { + // gives time to checkpoint + TimeUnit.SECONDS.sleep(1); + } + assertEquals(expectedCount, files.length); assertEquals(lastFileName, files[files.length-1].getName()); diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/selector/SelectorTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -21,6 +21,7 @@ import javax.jms.Message; import org.apache.activemq.command.ActiveMQMessage; +import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTextMessage; import org.apache.activemq.command.ActiveMQTopic; import org.apache.activemq.filter.BooleanExpression; @@ -364,6 +365,15 @@ assertSelector(message, "REGEX('connection1111', REPLACE(JMSMessageID,':',''))", true); } + public void testMatchOriginalDestinationAttribute() throws Exception { + + ActiveMQMessage activeMQMessage = (ActiveMQMessage) createMessage(); + ActiveMQQueue originalDest = new ActiveMQQueue("QQ"); + activeMQMessage.setOriginalDestination(originalDest); + assertSelector(activeMQMessage, "JMSDestination='" + originalDest.getQualifiedName() +"'", true); + } + + protected Message createMessage() throws JMSException { Message message = createMessage("FOO.BAR"); message.setJMSType("selector-test"); diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ActiveDurableSubscriptionBrowseExpireTest.java activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ActiveDurableSubscriptionBrowseExpireTest.java --- activemq-5.16.0/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ActiveDurableSubscriptionBrowseExpireTest.java 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/java/org/apache/activemq/usecases/ActiveDurableSubscriptionBrowseExpireTest.java 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,168 @@ +/** + * 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.usecases; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.LinkedList; + +import javax.jms.Connection; +import javax.jms.Message; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.management.ObjectName; +import javax.management.openmbean.CompositeData; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.TestSupport.PersistenceAdapterChoice; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean; +import org.apache.activemq.store.MessageRecoveryListener; +import org.apache.activemq.store.PersistenceAdapter; +import org.apache.activemq.store.TopicMessageStore; +import org.apache.activemq.broker.region.Destination; +import org.apache.activemq.command.MessageId; +import org.junit.Test; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(value = Parameterized.class) +public class ActiveDurableSubscriptionBrowseExpireTest extends DurableSubscriptionOfflineTestBase { + //private static final Logger LOG = LoggerFactory.getLogger(ActiveDurableSubscriptionBrowseExpireTest.class); + private boolean enableExpiration = true; + + public ActiveDurableSubscriptionBrowseExpireTest(boolean enableExpiration) { + keepDurableSubsActive = true; + this.enableExpiration = enableExpiration; + } + + @Parameterized.Parameters(name = "enableExpiration_{0}") + public static Collection data() { + return Arrays.asList(new Object[][] { + { false }, + { true } + }); + } + + @Override + public PersistenceAdapter setDefaultPersistenceAdapter(BrokerService broker) throws IOException { + return super.setPersistenceAdapter(broker, PersistenceAdapterChoice.MEM); + } + + @Override + protected ActiveMQConnectionFactory createConnectionFactory() throws Exception { + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + getName(true)); + connectionFactory.setWatchTopicAdvisories(false); + return connectionFactory; + } + + @Test(timeout = 60 * 1000) + public void testBrowseExpireActiveSub() throws Exception { + final int numberOfMessages = 10; + + broker.setEnableMessageExpirationOnActiveDurableSubs(enableExpiration); + + // create durable subscription + Connection con = createConnection("consumer"); + Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); + session.createDurableSubscriber(topic, "SubsId"); + + long timeStamp = System.currentTimeMillis(); + sendMessages(numberOfMessages, timeStamp); + + ObjectName[] subs = broker.getAdminView().getDurableTopicSubscribers(); + assertEquals(1, subs.length); + + ObjectName subName = subs[0]; + DurableSubscriptionViewMBean sub = (DurableSubscriptionViewMBean) + broker.getManagementContext().newProxyInstance(subName, DurableSubscriptionViewMBean.class, true); + assertEquals(true, sub.isActive()); + + // browse the durable sub + CompositeData[] data = sub.browse(); + assertNotNull(data); + assertEquals(numberOfMessages, data.length); + + Destination dest = broker.getDestination(topic); + assertEquals(0, dest.getDestinationStatistics().getExpired().getCount()); + + // add every 3rd message to the expiration list + TopicMessageStore topicStore = (TopicMessageStore)dest.getMessageStore(); + LinkedList messagesToExpire = new LinkedList<>(); + topicStore.recover(new MessageRecoveryListener() { + @Override + public boolean recoverMessage(org.apache.activemq.command.Message message) throws Exception { + int index = (int)message.getProperty("index"); + if(index % 3 == 0) + messagesToExpire.add(message); + return true; + } + + @Override + public boolean recoverMessageReference(MessageId messageReference) throws Exception { + return true; + } + + @Override + public boolean hasSpace() { + + return true; + } + + @Override + public boolean isDuplicate(MessageId id) { + return false; + } + }); + + // expire messages in the topic store + for(org.apache.activemq.command.Message message: messagesToExpire) { + message.setExpiration(timeStamp - 1); + topicStore.updateMessage(message); + } + + // browse (should | should not) expire the messages on the destination if expiration is (enabled | not enabled) + data = sub.browse(); + assertNotNull(data); + assertEquals(enableExpiration ? messagesToExpire.size() : 0, dest.getDestinationStatistics().getExpired().getCount()); + + session.close(); + con.close(); + } + + private void sendMessages(int numberOfMessages, long timeStamp) throws Exception { + Connection con = createConnection("producer"); + Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer producer = session.createProducer(null); + + for (int i = 0; i < numberOfMessages; i++) { + Message message = session.createMessage(); + message.setIntProperty("index", i); + message.setJMSTimestamp(timeStamp); + producer.send(topic, message); + } + + session.close(); + con.close(); + } +} diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/perf/networkSync.xml activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/perf/networkSync.xml --- activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/perf/networkSync.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/perf/networkSync.xml 2021-01-14 13:00:24.000000000 +0000 @@ -17,16 +17,15 @@ --> + http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> - + @@ -38,7 +37,7 @@ - + diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml --- activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-activecluster.xml 2021-01-14 13:00:24.000000000 +0000 @@ -15,7 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. --> - diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml --- activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/receiver-zeroconf.xml 2021-01-14 13:00:24.000000000 +0000 @@ -1,5 +1,4 @@ - diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml --- activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-activecluster.xml 2021-01-14 13:00:24.000000000 +0000 @@ -1,5 +1,4 @@ - diff -Nru activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml --- activemq-5.16.0/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-unit-tests/src/test/resources/org/apache/activemq/usecases/sender-zeroconf.xml 2021-01-14 13:00:24.000000000 +0000 @@ -1,5 +1,4 @@ - diff -Nru activemq-5.16.0/activemq-web/pom.xml activemq-5.16.1/activemq-web/pom.xml --- activemq-5.16.0/activemq-web/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-web/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-web @@ -55,6 +55,10 @@ activemq-pool + commons-io + commons-io + + ${project.groupId} activemq-unit-tests test diff -Nru activemq-5.16.0/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java activemq-5.16.1/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java --- activemq-5.16.0/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java 2021-01-14 13:00:24.000000000 +0000 @@ -19,6 +19,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -34,6 +35,7 @@ import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; +import org.apache.commons.io.input.BoundedInputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,6 +60,12 @@ public abstract class MessageServletSupport extends HttpServlet { private static final transient Logger LOG = LoggerFactory.getLogger(MessageServletSupport.class); + /** + * A configuration tag to specify the maximum message size (in bytes) for the servlet. The default + * is given by DEFAULT_MAX_MESSAGE_SIZE below. + */ + private static final String MAX_MESSAGE_SIZE_TAG = "maxMessageSize"; + private static final Long DEFAULT_MAX_MESSAGE_SIZE = 100000L; private boolean defaultTopicFlag = true; private Destination defaultDestination; @@ -68,6 +76,7 @@ private int defaultMessagePriority = 5; private long defaultMessageTimeToLive; private String destinationOptions; + private long maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE; public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); @@ -91,6 +100,11 @@ } } + String maxMessageSizeConfigured = servletConfig.getInitParameter(MAX_MESSAGE_SIZE_TAG); + if (maxMessageSizeConfigured != null) { + maxMessageSize = Long.parseLong(maxMessageSizeConfigured); + } + // lets check to see if there's a connection factory set WebClient.initContext(getServletContext()); } @@ -344,7 +358,8 @@ if (answer == null && contentType != null) { LOG.debug("Content-Type={}", contentType); // lets read the message body instead - BufferedReader reader = request.getReader(); + BoundedInputStream boundedInputStream = new BoundedInputStream(request.getInputStream(), maxMessageSize); + BufferedReader reader = new BufferedReader(new InputStreamReader(boundedInputStream)); StringBuilder buffer = new StringBuilder(); while (true) { String line = reader.readLine(); diff -Nru activemq-5.16.0/activemq-web-console/pom.xml activemq-5.16.1/activemq-web-console/pom.xml --- activemq-5.16.0/activemq-web-console/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-web-console/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-web-console diff -Nru activemq-5.16.0/activemq-web-console/src/main/webapp/decorators/header.jsp activemq-5.16.1/activemq-web-console/src/main/webapp/decorators/header.jsp --- activemq-5.16.0/activemq-web-console/src/main/webapp/decorators/header.jsp 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-web-console/src/main/webapp/decorators/header.jsp 2021-01-14 13:00:24.000000000 +0000 @@ -62,7 +62,9 @@ diff -Nru activemq-5.16.0/activemq-web-console/src/main/webapp/logout.jsp activemq-5.16.1/activemq-web-console/src/main/webapp/logout.jsp --- activemq-5.16.0/activemq-web-console/src/main/webapp/logout.jsp 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/activemq-web-console/src/main/webapp/logout.jsp 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,40 @@ +<%-- + 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. +--%> +<% +response.setStatus(401); +%> +<%@include file="WEB-INF/jspf/headertags.jspf" %> + + + + +<%@include file="decorators/head.jsp" %> + + + +<%@include file="decorators/header.jsp" %> + +

You have been logout

+ +

+Go back to Home to logon again. +

+ +<%@include file="decorators/footer.jsp" %> + + + \ No newline at end of file diff -Nru activemq-5.16.0/activemq-web-console/src/main/webapp/message.jsp activemq-5.16.1/activemq-web-console/src/main/webapp/message.jsp --- activemq-5.16.0/activemq-web-console/src/main/webapp/message.jsp 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-web-console/src/main/webapp/message.jsp 2021-01-14 13:00:24.000000000 +0000 @@ -234,9 +234,17 @@ return; } var value = select.options[selectedIndex].value; - var url = action + ".action?destination=" + value; - url += "&JMSDestination=${requestContext.messageQuery.JMSDestination}"; - url += "&messageId=${row.JMSMessageID}&JMSDestinationType=queue&secret=${sessionScope['secret']}"; + var url = action + ".action?destination=" + encodeURIComponent(value); + + var url = action + + " + + + + + "; + url = url + "&destination=" + encodeURIComponent(value); + if (confirm("Are you sure?")) location.href=url; } diff -Nru activemq-5.16.0/activemq-web-demo/pom.xml activemq-5.16.1/activemq-web-demo/pom.xml --- activemq-5.16.0/activemq-web-demo/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/activemq-web-demo/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 activemq-web-demo diff -Nru activemq-5.16.0/assembly/pom.xml activemq-5.16.1/assembly/pom.xml --- activemq-5.16.0/assembly/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/assembly/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -22,7 +22,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 apache-activemq @@ -467,6 +467,18 @@ com.fasterxml.jackson.core jackson-databind
+ + + + javax.xml.bind + jaxb-api + 2.2.11 + + + org.glassfish.jaxb + jaxb-runtime + 2.2.11 + diff -Nru activemq-5.16.0/assembly/src/main/descriptors/common-bin.xml activemq-5.16.1/assembly/src/main/descriptors/common-bin.xml --- activemq-5.16.0/assembly/src/main/descriptors/common-bin.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/assembly/src/main/descriptors/common-bin.xml 2021-01-14 13:00:24.000000000 +0000 @@ -146,6 +146,8 @@ org.apache.geronimo.specs:geronimo-jta_1.1_spec ${pom.groupId}:activemq-web org.fusesource.hawtbuf:hawtbuf + javax.xml.bind:jaxb-api + org.glassfish.jaxb:jaxb-runtime 0644 0755 @@ -182,6 +184,7 @@ ${pom.groupId}:activeio-core commons-beanutils:commons-beanutils commons-collections:commons-collections + commons-io:commons-io org.apache.commons:commons-dbcp2 org.apache.commons:commons-pool2 commons-codec:commons-codec diff -Nru activemq-5.16.0/assembly/src/release/bin/env activemq-5.16.1/assembly/src/release/bin/env --- activemq-5.16.0/assembly/src/release/bin/env 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/assembly/src/release/bin/env 2021-01-14 13:00:24.000000000 +0000 @@ -1,4 +1,3 @@ -#!/bin/sh # ------------------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with diff -Nru activemq-5.16.0/committer-tools/release-validate.sh activemq-5.16.1/committer-tools/release-validate.sh --- activemq-5.16.0/committer-tools/release-validate.sh 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/committer-tools/release-validate.sh 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,119 @@ +#!/bin/bash +# +# 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. +# + +export MVN_REPO=https://repo1.maven.org/maven2 + +export CMD_CURL=/usr/bin/curl +export CMD_MD5SUM=/sbin/md5 +export CMD_SHASUM=/usr/bin/shasum +export CMD_TAR=/usr/bin/tar +export CMD_UNZIP=/usr/bin/unzip + +download_media() { + + echo -n "Downloading ActiveMQ version: $1 type: $2..." + CURL_DL_OUT=`$CMD_CURL -s -o apache-activemq-$1-bin.$2 $MVN_REPO/org/apache/activemq/apache-activemq/$1/apache-activemq-$1-bin.$2` + echo "done" + + for kind in sha1 md5 + do + echo -n "Downloading ActiveMQ version: $1 type: $2 $kind checksum ..." + CURL_DL_CHKSUM_OUT=`$CMD_CURL -s -o apache-activemq-$1-bin.$2.$kind $MVN_REPO/org/apache/activemq/apache-activemq/$1/apache-activemq-$1-bin.$2.$kind` + echo "done" + + echo -n "Validating $kind checksum ..." + + if [ $kind = "sha1" ]; then + DL_CHKSUM=`$CMD_SHASUM apache-activemq-$1-bin.$2 | cut -f1 -d" "` + elif [ $kind = "md5" ]; then + DL_CHKSUM=`$CMD_MD5SUM -q apache-activemq-$1-bin.$2 | cut -f1 -d" "` + fi + VL_CHKSUM=`cut -f1 -d" " apache-activemq-$1-bin.$2.$kind` + + if [[ "$DL_CHKSUM" != "$VL_CHKSUM" ]]; then + echo "ERROR: $kind checksum mismatch expected: $VL_CHKSUM calculated: $DL_CHKSUM" + exit 1; + fi + echo "done" + done + +} + +extract_media() { + echo -n "Extracting $2 media ..." + + if [ $2 = "tar.gz" ]; then + EXTRACT_OUT=`$CMD_TAR xzf apache-activemq-$1-bin.$2` + elif [ $2 = "zip" ]; then + EXTRACT_OUT=`$CMD_UNZIP apache-activemq-$1-bin.$2` + fi + + if [[ $? -ne 0 ]]; then + echo "$2 extract failed!" + exit 1 + fi + echo "done" +} + +cleanup_media() { + echo -n "Cleaning up $2 media ...": + rm apache-activemq-$1-bin.$2.sha1 + rm apache-activemq-$1-bin.$2.md5 + rm apache-activemq-$1-bin.$2 + rm -rf apache-activemq-$1 + echo "done" +} + +if [ -z ${1+x} ]; then + echo "Using default maven repo: $MVN_REPO" +else + export MVN_REPO=$1 + echo "Using maven repo: $MVN_REPO" +fi + +VERSIONS=() +CURL_OUT=`$CMD_CURL -o index.html -s $MVN_REPO/org/apache/activemq/apache-activemq/` + +for i in `grep href index.html | grep -v maven-metadata | grep -v "\.\." | cut -f2 -d= | cut -f1 -d"/" | cut -f2 -d"\"" | sort -rV | grep -v -E '5.1.[0-9+]|5.8'`; +do + if [[ $i =~ 5.1[5-9]+ ]]; then + VERSIONS+=($i) + fi +done + +rm index.html + +VERSIONS+=("Quit") + +PS3='Install ActiveMQ version: ' +select opt in "${VERSIONS[@]}" +do + case $opt in + "Quit") + break;; + *) + for type in tar.gz zip + do + download_media $opt $type + extract_media $opt $type + cleanup_media $opt $type + done + break;; + esac +done + diff -Nru activemq-5.16.0/debian/changelog activemq-5.16.1/debian/changelog --- activemq-5.16.0/debian/changelog 2020-10-07 17:08:34.000000000 +0000 +++ activemq-5.16.1/debian/changelog 2021-03-02 16:08:31.000000000 +0000 @@ -1,3 +1,13 @@ +activemq (5.16.1-1) unstable; urgency=high + + * Team upload. + * New upstream version 5.16.1. + - Fix CVE-2021-26117: no check on LDAP user password (Closes: #982590) + Thanks to Salvatore Bonaccorso for the report. + * Declare compliance with Debian Policy 4.5.1. + + -- Markus Koschany Tue, 02 Mar 2021 17:08:31 +0100 + activemq (5.16.0-1) unstable; urgency=medium * Team upload. diff -Nru activemq-5.16.0/debian/control activemq-5.16.1/debian/control --- activemq-5.16.0/debian/control 2020-10-07 17:08:34.000000000 +0000 +++ activemq-5.16.1/debian/control 2021-03-02 16:08:31.000000000 +0000 @@ -68,7 +68,7 @@ libxstream-java (>= 1.4), libzookeeper-java, maven-debian-helper -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Vcs-Git: https://salsa.debian.org/java-team/activemq.git Vcs-Browser: https://salsa.debian.org/java-team/activemq Homepage: http://activemq.apache.org diff -Nru activemq-5.16.0/debian/patches/enable-activemq-jdbc-store-module.patch activemq-5.16.1/debian/patches/enable-activemq-jdbc-store-module.patch --- activemq-5.16.0/debian/patches/enable-activemq-jdbc-store-module.patch 2020-10-07 17:08:34.000000000 +0000 +++ activemq-5.16.1/debian/patches/enable-activemq-jdbc-store-module.patch 2021-03-02 16:08:31.000000000 +0000 @@ -7,8 +7,6 @@ pom.xml | 14 ++++++++++++++ 2 files changed, 24 insertions(+) -diff --git a/activemq-jdbc-store/pom.xml b/activemq-jdbc-store/pom.xml -index a347dd9..4266a94 100644 --- a/activemq-jdbc-store/pom.xml +++ b/activemq-jdbc-store/pom.xml @@ -54,6 +54,16 @@ @@ -28,24 +26,22 @@ -diff --git a/pom.xml b/pom.xml -index 3098a86..4a6dcb8 100644 --- a/pom.xml +++ b/pom.xml -@@ -53,10 +53,12 @@ +@@ -48,10 +48,12 @@ 1.9.4 3.2.2 - 1.2.2 + 1.2.3 + 1.4 - 2.7.0 - 2.6 + 2.8.0 + 2.8.0 2.6 1.2 + 1.6 - 2.8.0 + 2.9.0 1.0 - 3.6 -@@ -864,6 +866,18 @@ + 3.7.2 +@@ -834,6 +836,19 @@ ${commons-pool2-version} @@ -61,6 +57,7 @@ + ${commons-pool-version} + + - - + + activemq diff -Nru activemq-5.16.0/debian/patches/maven-xbean-plugin.patch activemq-5.16.1/debian/patches/maven-xbean-plugin.patch --- activemq-5.16.0/debian/patches/maven-xbean-plugin.patch 2020-10-07 17:08:34.000000000 +0000 +++ activemq-5.16.1/debian/patches/maven-xbean-plugin.patch 2021-03-02 16:08:31.000000000 +0000 @@ -8,8 +8,6 @@ pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -diff --git a/activemq-spring/pom.xml b/activemq-spring/pom.xml -index ecf8591..a7a5904 100644 --- a/activemq-spring/pom.xml +++ b/activemq-spring/pom.xml @@ -210,7 +210,7 @@ @@ -21,15 +19,13 @@ process-classes -diff --git a/pom.xml b/pom.xml -index 0e1e310..3098a86 100644 --- a/pom.xml +++ b/pom.xml -@@ -128,7 +128,7 @@ - 2.6.0_2 +@@ -113,7 +113,7 @@ + 2.7.2 1.1.4c - 1.4.11.1 -- 4.17 + 1.4.15 +- 4.18 + 4.5 2.12.0 0.6.4 diff -Nru activemq-5.16.0/Jenkinsfile activemq-5.16.1/Jenkinsfile --- activemq-5.16.0/Jenkinsfile 1970-01-01 00:00:00.000000000 +0000 +++ activemq-5.16.1/Jenkinsfile 2021-01-14 13:00:24.000000000 +0000 @@ -0,0 +1,164 @@ +#!groovy + +/* + * + * 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. + * + */ + +pipeline { + + agent { + node { + label 'ubuntu' + } + } + + environment { + // ... setup any environment variables ... + MVN_LOCAL_REPO_OPT = '-Dmaven.repo.local=.repository' + MVN_TEST_FAIL_IGNORE = '-Dmaven.test.failure.ignore=true' + } + + tools { + // ... tell Jenkins what java version, maven version or other tools are required ... + maven 'maven_3_latest' + jdk 'jdk_1.8_latest' + } + + options { + // Configure an overall timeout for the build of one hour. + timeout(time: 10, unit: 'HOURS') + // When we have test-fails e.g. we don't need to run the remaining steps + skipStagesAfterUnstable() + buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '5')) + } + + stages { + stage('Initialization') { + steps { + echo 'Building branch ' + env.BRANCH_NAME + echo 'Using PATH ' + env.PATH + } + } + + stage('Cleanup') { + steps { + echo 'Cleaning up the workspace' + deleteDir() + } + } + + stage('Checkout') { + steps { + echo 'Checking out branch ' + env.BRANCH_NAME + checkout scm + } + } + + stage('Build') { + steps { + echo 'Building' + sh 'mvn -U -B -e clean install -DskipTests' + } + } + + stage('Tests') { + steps { + echo 'Running tests' + // all tests is very very long (10 hours on Apache Jenkins) + // sh 'mvn -B -e test -pl activemq-unit-tests -Dactivemq.tests=all' + sh 'mvn -B -e test' + } + post { + always { + junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true) + junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true) + } + } + } + + stage('Deploy') { + when { + expression { + env.BRANCH_NAME ==~ /(activemq-5.16.x|activemq-5.15.x|master)/ + } + } + steps { + echo 'Deploying' + sh 'mvn -B -e deploy -Pdeploy -DskipTests' + } + } + } + + // Do any post build stuff ... such as sending emails depending on the overall build result. + post { + // If this build failed, send an email to the list. + failure { + script { + if(env.BRANCH_NAME == "activemq-5.15.x" || env.BRANCH_NAME == "activemq-5.16.x" || env.BRANCH_NAME == "master") { + emailext( + subject: "[BUILD-FAILURE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", + body: """ +BUILD-FAILURE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': +Check console output at "${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]" +""", + to: "commits@activemq.apache.org", + recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) + } + } + } + + // If this build didn't fail, but there were failing tests, send an email to the list. + unstable { + script { + if(env.BRANCH_NAME == "activemq-5.15.x" || env.BRANCH_NAME == "activemq-5.16.x" || env.BRANCH_NAME == "master") { + emailext( + subject: "[BUILD-UNSTABLE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", + body: """ +BUILD-UNSTABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': +Check console output at "${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]" +""", + to: "commits@activemq.apache.org", + recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) + } + } + } + + // Send an email, if the last build was not successful and this one is. + success { + // Cleanup the build directory if the build was successful + // (in this cae we probably don't have to do any post-build analysis) + deleteDir() + script { + if ((env.BRANCH_NAME == "activemq-5.15.x" || env.BRANCH_NAME == "activemq-5.16.x" || env.BRANCH_NAME == "master") && (currentBuild.previousBuild != null) && (currentBuild.previousBuild.result != 'SUCCESS')) { + emailext ( + subject: "[BUILD-STABLE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", + body: """ +BUILD-STABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': +Is back to normal. +""", + to: "commits@activemq.apache.org", + recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) + } + } + } + } + +} diff -Nru activemq-5.16.0/pom.xml activemq-5.16.1/pom.xml --- activemq-5.16.0/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/pom.xml 2021-01-14 13:00:24.000000000 +0000 @@ -25,7 +25,7 @@ org.apache.activemq activemq-parent - 5.16.0 + 5.16.1 pom ActiveMQ 2005 @@ -41,56 +41,47 @@ 1.1 1.3 0.1.0 - 1.10.7 - 1.10.7_1 - 1.0 1.1.0 - 1.1.1 1.0-M3-dev - 2.24.3 + 2.25.2 [2.20,3) - 2.2 1.9.4 3.2.2 - 1.2.2 - 2.7.0 - 2.6 + 1.2.3 + 2.8.0 + 2.8.0 2.6 1.2 - 2.8.0 + 2.9.0 1.0 - 3.6 + 3.7.2 2.0.0.AM25 3.17.0 1.1.1 - 1.0 28.2-jre 1.2.1 1.11 1.22 - 0.1.8 - 1.8.0.12 - 4.5.11 - 4.4.13 + 4.5.13 + 4.4.14 1.2.0.Beta4 2.9.10 - 2.9.10.4 + 2.9.10.8 1.9.3 2.2.11_1 - 9.4.28.v20200408 + 9.4.35.v20201120 ${jetty9-version} 3.4.1 - 9.0.35 + 9.0.41 1.4.1 2.5.1 1.6.2 1.5_5 1.1.1 - 4.12 + 4.13.1 1.3 - 2.0 - 4.2.8 + 4.2.10 0.9 0.9 1.8 @@ -99,36 +90,30 @@ 5.2.4 1.6.5 1.16 - 1.2.0 10.14.2.0 6.0.0 - 1.1.2 1.4.0 3.4.14 - 0.33.5 - 0.52.0 - 4.1.46.Final - 0.33.5 - 4.1.46.Final + 0.33.8 + 0.55.0 + 4.1.53.Final + 0.33.8 + 4.1.53.Final 1.3 - 1.12.2 - 9.5.1-5 - 9.5.1-5_1 + 1.15.0 3.1.0 2.11.11 - 1.5.3 + 1.7.0 3.0.8 1.7.30 1.1.2 - 4.3.26.RELEASE + 4.3.30.RELEASE 1.2.5 2.2 2.7.2 - 3.1.0 - 2.6.0_2 1.1.4c - 1.4.11.1 - 4.17 + 1.4.15 + 4.18 2.12.0 0.6.4 1.19 @@ -266,7 +251,7 @@ scm:git:http://gitbox.apache.org/repos/asf/activemq.git scm:git:https://gitbox.apache.org/repos/asf/activemq.git https://github.com/apache/activemq - activemq-5.16.0 + activemq-5.16.1 @@ -694,12 +679,6 @@ ${commons-collections-version} - - org.apache.openjpa - openjpa-persistence-jdbc - ${openjpa-version} - - org.apache.shiro @@ -843,15 +822,6 @@ ${regexp-version} - - - org.apache.commons commons-dbcp2 @@ -864,15 +834,6 @@ ${commons-pool2-version} - - - activemq @@ -886,21 +847,6 @@ 1.5.0 - - - - - - org.apache.xmlbeans - xmlbeans - ${xmlbeans-version} - - - org.apache.xmlbeans - xmlbeans-xpath - ${xmlbeans-version} - - activesoap @@ -993,12 +939,6 @@ - aopalliance - aopalliance - ${aopalliance-version} - - - org.jasypt jasypt ${jasypt-version} @@ -1077,12 +1017,6 @@ ${commons-io-version} - - org.apache.ant - ant - ${ant-version} - - com.rometools @@ -1096,17 +1030,6 @@ - p2psockets - p2psockets-core - ${p2psockets-version} - - - jxta - jxta - ${jxta-version} - - - org.slf4j slf4j-api ${slf4j-version} diff -Nru activemq-5.16.0/README.md activemq-5.16.1/README.md --- activemq-5.16.0/README.md 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/README.md 2021-01-14 13:00:24.000000000 +0000 @@ -8,20 +8,20 @@ To help you get started, try the following links: Getting Started -- http://activemq.apache.org/version-5-getting-started.html +- https://activemq.apache.org/version-5-getting-started.html Building -- http://activemq.apache.org/version-5-getting-started.html#GettingStarted-WindowsSourceInstallation -- http://activemq.apache.org/version-5-getting-started.html#GettingStarted-UnixSourceInstallation +- [Windows](https://activemq.apache.org/version-5-getting-started.html#installation-procedure-for-windows) +- [Unix](https://activemq.apache.org/version-5-getting-started.html#installation-procedure-for-unix) Examples -- http://activemq.apache.org/examples.html +- https://activemq.apache.org/examples.html We welcome contributions of all kinds, for details of how you can help -http://activemq.apache.org/contributing.html +https://activemq.apache.org/contributing.html Please refer to the website for details of finding the issue tracker, -email lists, wiki or IRC channel at http://activemq.apache.org/ +email lists, wiki or IRC channel at https://activemq.apache.org/ Please help us make Apache ActiveMQ better - we appreciate any feedback you may have. @@ -32,7 +32,7 @@ ======================================================================= This software is licensed under the terms you may find in the file - named "LICENSE" in this directory. + named "[LICENSE](./LICENSE)" in this directory. This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, @@ -40,7 +40,7 @@ encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to - see if this is permitted. See for more + see if this is permitted. See for more information. The U.S. Government Department of Commerce, Bureau of Industry and @@ -58,6 +58,6 @@ ActiveMQ supports the use of SSL TCP connections when used with with a JVM supporting the Java Cryptography extensions - . + . ActiveMQ does not include these libraries itself, but is designed to use them. diff -Nru activemq-5.16.0/trash/activemq-optional/pom.xml activemq-5.16.1/trash/activemq-optional/pom.xml --- activemq-5.16.0/trash/activemq-optional/pom.xml 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/pom.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ - - - - - 4.0.0 - - - org.apache.activemq - activemq-parent - 5.9-SNAPSHOT - - - activemq-optional - jar - ActiveMQ :: Optional - Optional ActiveMQ features - - - - - ${project.groupId} - activemq-client - - - org.slf4j - slf4j-api - - - ${project.groupId} - activemq-broker - test-jar - test - - - ${project.groupId} - activeio-core - - - ${project.groupId} - activemq-console - - - org.springframework - spring-core - - - org.springframework - spring-jms - - - aopalliance - aopalliance - - - com.thoughtworks.xstream - xstream - - - xpp3 - xpp3 - - - org.eclipse.jetty.aggregate - jetty-all-server - - - org.eclipse.jetty - jetty-webapp - ${jetty-version} - - - org.eclipse.jetty - jetty-websocket - ${jetty-version} - - - org.apache.httpcomponents - httpclient - - - org.apache.commons - commons-pool2 - - - commons-collections - commons-collections - - - commons-logging - commons-logging - test - - - - log4j - log4j - compile - true - - - junit - junit - compile - true - - - org.apache.xmlbeans - xmlbeans - true - - - org.apache.xmlbeans - xmlbeans-xpath - true - - - net.sf.saxon - saxon - - - - - net.sf.saxon - Saxon-HE - ${saxon-version} - true - - - xerces - xercesImpl - ${xerces-version} - true - - - xalan - xalan - true - - - org.slf4j - slf4j-log4j12 - test - - - org.springframework - spring-oxm - true - - - org.apache.xbean - xbean-spring - test - - - org.codehaus.jettison - jettison - test - - - - org.seleniumhq.selenium - selenium-java - 2.25.0 - test - - - org.seleniumhq.selenium - selenium-chrome-driver - 2.25.0 - test - - - org.seleniumhq.selenium - selenium-firefox-driver - 2.25.0 - test - - - - - - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - org.apache.felix - maven-bundle-plugin - - - ${project.artifactId} - org.apache.activemq.activemq-core - - org.apache.activemq.transport.http*;version=${project.version};-noimport:=;-split-package:=merge-last, - org.apache.activemq.transport.https*;version=${project.version};-noimport:=;-split-package:=merge-last - - - org.eclipse.jetty*;version="[7.6,8.0)";resolution:=optional, - !org.apache.activemq.transport.ws*;version=${project.version}, - !org.apache.activemq.transport.xstream;version=${project.version}, - !org.apache.activemq.transport.util;version=${project.version}, - org.apache.activemq*;version=${project.version};resolution:=optional - - - - - - bundle-manifest - process-classes - - manifest - - - - - - - maven-surefire-plugin - - - - - - diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/BenchmarkSupport.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/BenchmarkSupport.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/BenchmarkSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/BenchmarkSupport.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,220 +0,0 @@ -/** - * 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.benchmark; - -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Session; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.util.IdGenerator; - -/** - * Abstract base class for some simple benchmark tools - */ -public class BenchmarkSupport { - - protected int connectionCount = 1; - protected int batch = 1000; - protected Destination destination; - protected String[] subjects; - - private boolean topic = true; - private boolean durable; - private ActiveMQConnectionFactory factory; - private String url; - private int counter; - private List resources = new ArrayList(); - private NumberFormat formatter = NumberFormat.getInstance(); - private AtomicInteger connectionCounter = new AtomicInteger(0); - private IdGenerator idGenerator = new IdGenerator(); - private boolean timerLoop; - - public BenchmarkSupport() { - } - - public void start() { - System.out.println("Using: " + connectionCount + " connection(s)"); - subjects = new String[connectionCount]; - for (int i = 0; i < connectionCount; i++) { - subjects[i] = "BENCHMARK.FEED" + i; - } - if (useTimerLoop()) { - Thread timer = new Thread() { - public void run() { - timerLoop(); - } - }; - timer.start(); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public boolean isTopic() { - return topic; - } - - public void setTopic(boolean topic) { - this.topic = topic; - } - - public ActiveMQConnectionFactory getFactory() { - return factory; - } - - public void setFactory(ActiveMQConnectionFactory factory) { - this.factory = factory; - } - - public void setSubject(String subject) { - connectionCount = 1; - subjects = new String[] { - subject - }; - } - - public boolean isDurable() { - return durable; - } - - public void setDurable(boolean durable) { - this.durable = durable; - } - - public int getConnectionCount() { - return connectionCount; - } - - public void setConnectionCount(int connectionCount) { - this.connectionCount = connectionCount; - } - - protected Session createSession() throws JMSException { - if (factory == null) { - factory = createFactory(); - } - Connection connection = factory.createConnection(); - int value = connectionCounter.incrementAndGet(); - System.out.println("Created connection: " + value + " = " + connection); - if (durable) { - connection.setClientID(idGenerator.generateId()); - } - addResource(connection); - connection.start(); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - addResource(session); - return session; - } - - protected ActiveMQConnectionFactory createFactory() { - ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory(getUrl()); - return answer; - } - - protected synchronized void count(int count) { - counter += count; - /* - * if (counter > batch) { counter = 0; long current = - * System.currentTimeMillis(); double end = current - time; end /= 1000; - * time = current; System.out.println("Processed " + batch + " messages - * in " + end + " (secs)"); } - */ - } - - protected synchronized int resetCount() { - int answer = counter; - counter = 0; - return answer; - } - - protected void timerLoop() { - int times = 0; - int total = 0; - int dumpVmStatsFrequency = 10; - Runtime runtime = Runtime.getRuntime(); - - while (true) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - int processed = resetCount(); - double average = 0; - if (processed > 0) { - total += processed; - times++; - } - if (times > 0) { - average = total / (double) times; - } - - System.out.println(getClass().getName() + " Processed: " + processed + " messages this second. Average: " + average); - - if ((times % dumpVmStatsFrequency) == 0 && times != 0) { - System.out.println("Used memory: " + asMemoryString(runtime.totalMemory() - runtime.freeMemory()) + " Free memory: " + asMemoryString(runtime.freeMemory()) + " Total memory: " - + asMemoryString(runtime.totalMemory()) + " Max memory: " + asMemoryString(runtime.maxMemory())); - } - - } - } - - protected String asMemoryString(long value) { - return formatter.format(value / 1024) + " K"; - } - - protected boolean useTimerLoop() { - return timerLoop; - } - - protected Destination createDestination(Session session, String subject) throws JMSException { - if (topic) { - return session.createTopic(subject); - } else { - return session.createQueue(subject); - } - } - - protected void addResource(Object resource) { - resources.add(resource); - } - - public int getCounter() { - return counter; - } - - public void setTimerLoop(boolean timerLoop) { - this.timerLoop = timerLoop; - } - - protected static boolean parseBoolean(String text) { - return text.equalsIgnoreCase("true"); - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Consumer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Consumer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Consumer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Consumer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/** - * 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.benchmark; - -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - -public class Consumer extends BenchmarkSupport implements MessageListener { - - public Consumer() { - } - - public static void main(String[] args) { - Consumer tool = new Consumer(); - if (args.length > 0) { - tool.setUrl(args[0]); - } - if (args.length > 1) { - tool.setTopic(parseBoolean(args[1])); - } - if (args.length > 2) { - tool.setSubject(args[2]); - } - if (args.length > 3) { - tool.setDurable(parseBoolean(args[3])); - } - if (args.length > 4) { - tool.setConnectionCount(Integer.parseInt(args[4])); - } - - try { - tool.run(); - } catch (Exception e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - - public void run() throws JMSException { - start(); - subscribe(); - } - - protected void subscribe() throws JMSException { - for (int i = 0; i < subjects.length; i++) { - subscribe(subjects[i]); - } - } - - protected void subscribe(String subject) throws JMSException { - Session session = createSession(); - - Destination destination = createDestination(session, subject); - - System.out.println("Consuming on : " + destination + " of type: " + destination.getClass().getName()); - - MessageConsumer consumer = null; - if (isDurable() && isTopic()) { - consumer = session.createDurableSubscriber((Topic)destination, getClass().getName()); - } else { - consumer = session.createConsumer(destination); - } - consumer.setMessageListener(this); - addResource(consumer); - } - - public void onMessage(Message message) { - try { - TextMessage textMessage = (TextMessage)message; - - // lets force the content to be deserialized - textMessage.getText(); - count(1); - - // lets count the messages - - // message.acknowledge(); - } catch (JMSException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/ProducerConsumer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/ProducerConsumer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/ProducerConsumer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/ProducerConsumer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/** - * 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.benchmark; - -public class ProducerConsumer extends Producer { - - private Consumer consumer = new Consumer(); - - public ProducerConsumer() { - } - - public static void main(String[] args) { - ProducerConsumer tool = new ProducerConsumer(); - if (args.length > 0) { - tool.setUrl(args[0]); - } - if (args.length > 1) { - tool.setTopic(parseBoolean(args[1])); - } - if (args.length > 2) { - tool.setSubject(args[2]); - } - if (args.length > 3) { - tool.setDurable(Boolean.getBoolean(args[3])); - } - if (args.length > 4) { - tool.setConnectionCount(Integer.parseInt(args[4])); - } - try { - tool.run(); - } catch (Exception e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - - public void run() throws Exception { - consumer.start(); - consumer.subscribe(); - start(); - publish(); - } - - public void setTopic(boolean topic) { - super.setTopic(topic); - consumer.setTopic(topic); - } - - public void setSubject(String subject) { - super.setSubject(subject); - consumer.setSubject(subject); - } - - public void setUrl(String url) { - super.setUrl(url); - consumer.setUrl(url); - } - - protected boolean useTimerLoop() { - return false; - } - - public Consumer getConsumer() { - return consumer; - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Producer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Producer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Producer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/benchmark/Producer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ -/** - * 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.benchmark; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Session; - -public class Producer extends BenchmarkSupport { - - int loops = -1; - int loopSize = 1000; - private int messageSize = 1000; - - public Producer() { - } - - public static void main(String[] args) { - Producer tool = new Producer(); - if (args.length > 0) { - tool.setUrl(args[0]); - } - if (args.length > 1) { - tool.setTopic(parseBoolean(args[1])); - } - if (args.length > 2) { - tool.setSubject(args[2]); - } - if (args.length > 3) { - tool.setDurable(parseBoolean(args[3])); - } - if (args.length > 4) { - tool.setMessageSize(Integer.parseInt(args[4])); - } - if (args.length > 5) { - tool.setConnectionCount(Integer.parseInt(args[5])); - } - try { - tool.run(); - } catch (Exception e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - - public void run() throws Exception { - start(); - publish(); - } - - // Properties - // ------------------------------------------------------------------------- - public int getMessageSize() { - return messageSize; - } - - public void setMessageSize(int messageSize) { - this.messageSize = messageSize; - } - - public int getLoopSize() { - return loopSize; - } - - public void setLoopSize(int loopSize) { - this.loopSize = loopSize; - } - - // Implementation methods - // ------------------------------------------------------------------------- - - protected void publish() throws Exception { - final String text = getMessage(); - - System.out.println("Publishing to: " + subjects.length + " subject(s)"); - - for (int i = 0; i < subjects.length; i++) { - final String subject = subjects[i]; - Thread thread = new Thread() { - public void run() { - try { - publish(text, subject); - } catch (JMSException e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - }; - thread.start(); - } - - } - - protected String getMessage() { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < messageSize; i++) { - char ch = 'X'; - buffer.append(ch); - } - return buffer.toString(); - } - - protected void publish(String text, String subject) throws JMSException { - Session session = createSession(); - - Destination destination = createDestination(session, subject); - - MessageProducer publisher = session.createProducer(destination); - if (isDurable()) { - publisher.setDeliveryMode(DeliveryMode.PERSISTENT); - } else { - publisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - } - - System.out.println("Starting publisher on : " + destination + " of type: " + destination.getClass().getName()); - System.out.println("Message length: " + text.length()); - - if (loops <= 0) { - while (true) { - publishLoop(session, publisher, text); - } - } else { - for (int i = 0; i < loops; i++) { - publishLoop(session, publisher, text); - } - } - } - - protected void publishLoop(Session session, MessageProducer publisher, String text) throws JMSException { - for (int i = 0; i < loopSize; i++) { - Message message = session.createTextMessage(text); - - publisher.send(message); - count(1); - } - } - - protected String loadFile(String file) throws IOException { - System.out.println("Loading file: " + file); - - StringBuffer buffer = new StringBuffer(); - BufferedReader in = new BufferedReader(new FileReader(file)); - while (true) { - String line = in.readLine(); - if (line == null) { - break; - } - buffer.append(line); - buffer.append(File.separator); - } - in.close(); - return buffer.toString(); - } - - public int getLoops() { - return loops; - } - - public void setLoops(int loops) { - this.loops = loops; - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/AcidTestTool.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/AcidTestTool.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/AcidTestTool.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/AcidTestTool.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,362 +0,0 @@ -/** - * 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.tool; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; - -import junit.framework.TestCase; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQQueue; - -/** - * - */ -public class AcidTestTool extends TestCase { - - - // Worker configuration. - protected int recordSize = 1024; - protected int batchSize = 5; - protected int workerThinkTime = 500; - protected Destination target; - - private Random random = new Random(); - private byte data[]; - private int workerCount = 10; - private AtomicBoolean ignoreJMSErrors = new AtomicBoolean(false); - private ActiveMQConnectionFactory factory; - private Connection connection; - private AtomicInteger publishedBatches = new AtomicInteger(0); - private AtomicInteger consumedBatches = new AtomicInteger(0); - private List errors = Collections.synchronizedList(new ArrayList()); - - private interface Worker extends Runnable { - boolean waitForExit(long i) throws InterruptedException; - } - - private final class ProducerWorker implements Worker { - - private Session session; - private MessageProducer producer; - private BytesMessage message; - private CountDownLatch doneLatch = new CountDownLatch(1); - - ProducerWorker(Session session, String workerId) throws JMSException { - this.session = session; - producer = session.createProducer(target); - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - message = session.createBytesMessage(); - message.setStringProperty("workerId", workerId); - message.writeBytes(data); - } - - public void run() { - try { - for (int batchId = 0; true; batchId++) { - // System.out.println("Sending batch: "+workerId+" - // "+batchId); - for (int msgId = 0; msgId < batchSize; msgId++) { - // Sleep some random amount of time less than - // workerThinkTime - try { - Thread.sleep(random.nextInt(workerThinkTime)); - } catch (InterruptedException e1) { - return; - } - - message.setIntProperty("batch-id", batchId); - message.setIntProperty("msg-id", msgId); - - producer.send(message); - } - session.commit(); - publishedBatches.incrementAndGet(); - // System.out.println("Commited send batch: "+workerId+" - // "+batchId); - } - } catch (JMSException e) { - if (!ignoreJMSErrors.get()) { - e.printStackTrace(); - errors.add(e); - } - return; - } catch (Throwable e) { - e.printStackTrace(); - errors.add(e); - return; - } finally { - System.out.println("Producer exiting."); - doneLatch.countDown(); - } - } - - public boolean waitForExit(long i) throws InterruptedException { - return doneLatch.await(i, TimeUnit.MILLISECONDS); - } - } - - private final class ConsumerWorker implements Worker { - - private Session session; - private MessageConsumer consumer; - private final long timeout; - private CountDownLatch doneLatch = new CountDownLatch(1); - - ConsumerWorker(Session session, String workerId, long timeout) throws JMSException { - this.session = session; - this.timeout = timeout; - consumer = session.createConsumer(target, "workerId='" + workerId + "'"); - } - - public void run() { - - try { - int batchId = 0; - while (true) { - for (int msgId = 0; msgId < batchSize; msgId++) { - - // Sleep some random amount of time less than - // workerThinkTime - try { - Thread.sleep(random.nextInt(workerThinkTime)); - } catch (InterruptedException e1) { - return; - } - - Message message = consumer.receive(timeout); - if (msgId > 0) { - assertNotNull(message); - assertEquals(message.getIntProperty("batch-id"), batchId); - assertEquals(message.getIntProperty("msg-id"), msgId); - } else { - if (message == null) { - System.out.println("At end of batch an don't have a next batch to process. done."); - return; - } - assertEquals(msgId, message.getIntProperty("msg-id")); - batchId = message.getIntProperty("batch-id"); - // System.out.println("Receiving batch: "+workerId+" - // "+batchId); - } - - } - session.commit(); - consumedBatches.incrementAndGet(); - // System.out.println("Commited receive batch: "+workerId+" - // "+batchId); - } - } catch (JMSException e) { - if (!ignoreJMSErrors.get()) { - e.printStackTrace(); - errors.add(e); - } - return; - } catch (Throwable e) { - e.printStackTrace(); - errors.add(e); - return; - } finally { - System.out.println("Consumer exiting."); - doneLatch.countDown(); - } - } - - public boolean waitForExit(long i) throws InterruptedException { - return doneLatch.await(i, TimeUnit.MILLISECONDS); - } - } - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - factory = new ActiveMQConnectionFactory("tcp://localhost:61616"); - this.target = new ActiveMQQueue(getClass().getName()); - } - - protected void tearDown() throws Exception { - if (connection != null) { - try { - connection.close(); - } catch (Throwable ignore) { - } - connection = null; - } - } - - /** - * @throws InterruptedException - * @throws JMSException - * @throws JMSException - */ - private void reconnect() throws InterruptedException, JMSException { - if (connection != null) { - try { - connection.close(); - } catch (Throwable ignore) { - } - connection = null; - } - - long reconnectDelay = 1000; - - while (connection == null) { - if (reconnectDelay > 1000 * 10) { - reconnectDelay = 1000 * 10; - } - try { - connection = factory.createConnection(); - connection.start(); - } catch (JMSException e) { - Thread.sleep(reconnectDelay); - reconnectDelay *= 2; - } - } - } - - /** - * @throws Throwable - * @throws IOException - */ - public void testAcidTransactions() throws Throwable { - - System.out.println("Client threads write records using: Record Size: " + recordSize + ", Batch Size: " + batchSize + ", Worker Think Time: " + workerThinkTime); - - // Create the record and fill it with some values. - data = new byte[recordSize]; - for (int i = 0; i < data.length; i++) { - data[i] = (byte)i; - } - - System.out.println("=============================================="); - System.out.println("===> Start the server now."); - System.out.println("=============================================="); - reconnect(); - - System.out.println("Starting " + workerCount + " Workers..."); - ArrayList workers = new ArrayList(); - for (int i = 0; i < workerCount; i++) { - String workerId = "worker-" + i; - - Worker w = new ConsumerWorker(connection.createSession(true, Session.SESSION_TRANSACTED), workerId, 1000 * 5); - workers.add(w); - new Thread(w, "Consumer:" + workerId).start(); - - w = new ProducerWorker(connection.createSession(true, Session.SESSION_TRANSACTED), workerId); - workers.add(w); - new Thread(w, "Producer:" + workerId).start(); - } - - System.out.println("Waiting for " + (workerCount * 10) + " batches to be delivered."); - - // - // Wait for about 5 batches of messages per worker to be consumed before - // restart. - // - while (publishedBatches.get() < workerCount * 5) { - System.out.println("Stats: Produced Batches: " + this.publishedBatches.get() + ", Consumed Batches: " + this.consumedBatches.get()); - Thread.sleep(1000); - } - - System.out.println("=============================================="); - System.out.println("===> Server is under load now. Kill it!"); - System.out.println("=============================================="); - ignoreJMSErrors.set(true); - - // Wait for all the workers to finish. - System.out.println("Waiting for all workers to exit due to server shutdown."); - for (Iterator iter = workers.iterator(); iter.hasNext();) { - Worker worker = iter.next(); - while (!worker.waitForExit(1000)) { - System.out.println("=============================================="); - System.out.println("===> Server is under load now. Kill it!"); - System.out.println("=============================================="); - System.out.println("Stats: Produced Batches: " + this.publishedBatches.get() + ", Consumed Batches: " + this.consumedBatches.get()); - } - } - workers.clear(); - - // No errors should have occurred so far. - if (errors.size() > 0) { - throw errors.get(0); - } - - System.out.println("=============================================="); - System.out.println("===> Start the server now."); - System.out.println("=============================================="); - reconnect(); - - System.out.println("Restarted."); - - // Validate the all transactions were commited as a uow. Looking for - // partial commits. - for (int i = 0; i < workerCount; i++) { - String workerId = "worker-" + i; - Worker w = new ConsumerWorker(connection.createSession(true, Session.SESSION_TRANSACTED), workerId, 5 * 1000); - workers.add(w); - new Thread(w, "Consumer:" + workerId).start(); - } - - System.out.println("Waiting for restarted consumers to finish consuming all messages.."); - for (Iterator iter = workers.iterator(); iter.hasNext();) { - Worker worker = iter.next(); - while (!worker.waitForExit(1000 * 5)) { - System.out.println("Waiting for restarted consumers to finish consuming all messages.."); - System.out.println("Stats: Produced Batches: " + this.publishedBatches.get() + ", Consumed Batches: " + this.consumedBatches.get()); - } - } - workers.clear(); - - System.out.println("Workers finished.."); - System.out.println("Stats: Produced Batches: " + this.publishedBatches.get() + ", Consumed Batches: " + this.consumedBatches.get()); - - if (errors.size() > 0) { - throw errors.get(0); - } - - } - - public static void main(String[] args) { - try { - AcidTestTool tool = new AcidTestTool(); - tool.setUp(); - tool.testAcidTransactions(); - tool.tearDown(); - } catch (Throwable e) { - System.out.println("Test Failed: " + e.getMessage()); - e.printStackTrace(); - } - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ConsumerTool.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ConsumerTool.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ConsumerTool.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ConsumerTool.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -/** - * 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.tool; - -import java.io.IOException; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; - -/** - * A simple tool for consuming messages - * - * - */ -public class ConsumerTool extends ToolSupport implements MessageListener { - - protected int count; - protected int dumpCount = 10; - protected boolean verbose = true; - protected int maxiumMessages; - private boolean pauseBeforeShutdown; - - public static void main(String[] args) { - ConsumerTool tool = new ConsumerTool(); - if (args.length > 0) { - tool.url = args[0]; - } - if (args.length > 1) { - tool.topic = args[1].equalsIgnoreCase("true"); - } - if (args.length > 2) { - tool.subject = args[2]; - } - if (args.length > 3) { - tool.durable = args[3].equalsIgnoreCase("true"); - } - if (args.length > 4) { - tool.maxiumMessages = Integer.parseInt(args[4]); - } - tool.run(); - } - - public void run() { - try { - System.out.println("Connecting to URL: " + url); - System.out.println("Consuming " + (topic ? "topic" : "queue") + ": " + subject); - System.out.println("Using " + (durable ? "durable" : "non-durable") + " subscription"); - - Connection connection = createConnection(); - Session session = createSession(connection); - MessageConsumer consumer = null; - if (durable && topic) { - consumer = session.createDurableSubscriber((Topic)destination, consumerName); - } else { - consumer = session.createConsumer(destination); - } - if (maxiumMessages <= 0) { - consumer.setMessageListener(this); - } - connection.start(); - - if (maxiumMessages > 0) { - consumeMessagesAndClose(connection, session, consumer); - } - } catch (Exception e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - - public void onMessage(Message message) { - try { - if (message instanceof TextMessage) { - TextMessage txtMsg = (TextMessage)message; - if (verbose) { - - String msg = txtMsg.getText(); - if (msg.length() > 50) { - msg = msg.substring(0, 50) + "..."; - } - - System.out.println("Received: " + msg); - } - } else { - if (verbose) { - System.out.println("Received: " + message); - } - } - /* - * if (++count % dumpCount == 0) { dumpStats(connection); } - */ - } catch (JMSException e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - - protected void consumeMessagesAndClose(Connection connection, Session session, MessageConsumer consumer) throws JMSException, IOException { - System.out.println("We are about to wait until we consume: " + maxiumMessages + " message(s) then we will shutdown"); - - for (int i = 0; i < maxiumMessages; i++) { - Message message = consumer.receive(); - onMessage(message); - } - System.out.println("Closing connection"); - consumer.close(); - session.close(); - connection.close(); - if (pauseBeforeShutdown) { - System.out.println("Press return to shut down"); - System.in.read(); - } - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/JndiProducerTool.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/JndiProducerTool.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/JndiProducerTool.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/JndiProducerTool.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/** - * 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.tool; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Queue; -import javax.naming.InitialContext; - -/** - * - */ -public class JndiProducerTool extends ProducerTool { - - public static void main(String[] args) { - runTool(args, new JndiProducerTool()); - } - - protected Connection createConnection() throws Exception { - InitialContext jndiContext = new InitialContext(); - - ConnectionFactory queueConnectionFactory = (ConnectionFactory) jndiContext.lookup("ConnectionFactory"); - Connection connection = queueConnectionFactory.createConnection(); - destination = (Queue) jndiContext.lookup(subject); - return connection; - - } - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ProducerTool.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ProducerTool.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ProducerTool.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ProducerTool.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ -/** - * 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.tool; - -import java.util.Date; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - -/** - * A simple tool for publishing messages - * - * - */ -public class ProducerTool extends ToolSupport { - - protected int messageCount = 10; - protected long sleepTime; - protected boolean verbose = true; - protected int messageSize = 255; - - public static void main(String[] args) { - runTool(args, new ProducerTool()); - } - - protected static void runTool(String[] args, ProducerTool tool) { - if (args.length > 0) { - tool.url = args[0]; - } - if (args.length > 1) { - tool.topic = args[1].equalsIgnoreCase("true"); - } - if (args.length > 2) { - tool.subject = args[2]; - } - if (args.length > 3) { - tool.durable = args[3].equalsIgnoreCase("true"); - } - if (args.length > 4) { - tool.messageCount = Integer.parseInt(args[4]); - } - if (args.length > 5) { - tool.messageSize = Integer.parseInt(args[5]); - } - tool.run(); - } - - public void run() { - try { - System.out.println("Connecting to URL: " + url); - System.out.println("Publishing a Message with size " + messageSize + " to " + (topic ? "topic" : "queue") + ": " + subject); - System.out.println("Using " + (durable ? "durable" : "non-durable") + " publishing"); - - Connection connection = createConnection(); - Session session = createSession(connection); - MessageProducer producer = createProducer(session); - // connection.start(); - - sendLoop(session, producer); - - System.out.println("Done."); - close(connection, session); - } catch (Exception e) { - System.out.println("Caught: " + e); - e.printStackTrace(); - } - } - - protected MessageProducer createProducer(Session session) throws JMSException { - MessageProducer producer = session.createProducer(destination); - if (durable) { - producer.setDeliveryMode(DeliveryMode.PERSISTENT); - } else { - producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); - } - return producer; - } - - protected void sendLoop(Session session, MessageProducer producer) throws Exception { - - for (int i = 0; i < messageCount; i++) { - - TextMessage message = session.createTextMessage(createMessageText(i)); - - if (verbose) { - String msg = message.getText(); - if (msg.length() > 50) { - msg = msg.substring(0, 50) + "..."; - } - System.out.println("Sending message: " + msg); - } - - producer.send(message); - Thread.sleep(sleepTime); - } - producer.send(session.createMessage()); - } - - /** - * @param i - * @return - */ - private String createMessageText(int index) { - StringBuffer buffer = new StringBuffer(messageSize); - buffer.append("Message: " + index + " sent at: " + new Date()); - if (buffer.length() > messageSize) { - return buffer.substring(0, messageSize); - } - for (int i = buffer.length(); i < messageSize; i++) { - buffer.append(' '); - } - return buffer.toString(); - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ToolSupport.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ToolSupport.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ToolSupport.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/ToolSupport.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/** - * 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.tool; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Session; - -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.util.IndentPrinter; - -/** - * Abstract base class useful for implementation inheritence - * - * - */ -public class ToolSupport { - - protected Destination destination; - protected String subject = "TOOL.DEFAULT"; - protected boolean topic = true; - protected String user = ActiveMQConnection.DEFAULT_USER; - protected String pwd = ActiveMQConnection.DEFAULT_PASSWORD; - protected String url = ActiveMQConnection.DEFAULT_BROKER_URL; - protected boolean transacted; - protected boolean durable; - protected String clientID = getClass().getName(); - protected int ackMode = Session.AUTO_ACKNOWLEDGE; - protected String consumerName = "James"; - - protected Session createSession(Connection connection) throws Exception { - if (durable) { - connection.setClientID(clientID); - } - Session session = connection.createSession(transacted, ackMode); - if (topic) { - destination = session.createTopic(subject); - } else { - destination = session.createQueue(subject); - } - return session; - } - - protected Connection createConnection() throws JMSException, Exception { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, pwd, url); - return connectionFactory.createConnection(); - } - - protected void close(Connection connection, Session session) throws JMSException { - // lets dump the stats - dumpStats(connection); - - if (session != null) { - session.close(); - } - if (connection != null) { - connection.close(); - } - } - - protected void dumpStats(Connection connection) { - ActiveMQConnection c = (ActiveMQConnection)connection; - c.getConnectionStats().dump(new IndentPrinter()); - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/WebServer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/WebServer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/tool/WebServer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/tool/WebServer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/** - * 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.tool; - -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.bio.SocketConnector; -import org.eclipse.jetty.webapp.WebAppContext; - -/** - * - */ -public final class WebServer { - - public static final int PORT = 8080; - // public static final String WEBAPP_DIR = "target/activemq"; - public static final String WEBAPP_DIR = "src/webapp"; - public static final String WEBAPP_CTX = "/"; - - private WebServer() { - } - - public static void main(String[] args) throws Exception { - Server server = new Server(); - Connector context = new SocketConnector(); - context.setServer(server); - context.setPort(PORT); - - String webappDir = WEBAPP_DIR; - if (args.length > 0) { - webappDir = args[0]; - } - - WebAppContext webapp = new WebAppContext(); - webapp.setServer(server); - webapp.setContextPath(WEBAPP_CTX); - webapp.setResourceBase(webappDir); - - server.setHandler(webapp); - - server.setConnectors(new Connector[] { - context - }); - server.start(); - - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -/** - * 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.util.oxm; - -import java.io.Serializable; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.activemq.MessageTransformerSupport; - -/** - * Abstract class used as a base for implementing transformers from object to text messages (in XML/JSON format) - * and vice versa using. - * Supports plugging of custom marshallers - */ -public abstract class AbstractXMLMessageTransformer extends - MessageTransformerSupport { - - protected MessageTransform transformType; - - /** - * Defines the type of transformation. If XML (default), - producer - * transformation transforms from Object to XML. - consumer transformation - * transforms from XML to Object. If OBJECT, - producer transformation - * transforms from XML to Object. - consumer transformation transforms from - * Object to XML. If ADAPTIVE, - producer transformation transforms from - * Object to XML, or XML to Object depending on the type of the original - * message - consumer transformation transforms from XML to Object, or - * Object to XML depending on the type of the original message - */ - public enum MessageTransform { - XML, OBJECT, ADAPTIVE - }; - - - public AbstractXMLMessageTransformer() { - this(MessageTransform.XML); - } - - public AbstractXMLMessageTransformer(MessageTransform transformType) { - this.transformType = transformType; - } - - public Message consumerTransform(Session session, MessageConsumer consumer, Message message) throws JMSException { - switch (transformType) { - case XML: - return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : message; - case OBJECT: - return (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message; - case ADAPTIVE: - return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message; - default: - } - return message; - } - - public Message producerTransform(Session session, MessageProducer producer, Message message) throws JMSException { - switch (transformType) { - case XML: - return (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message; - case OBJECT: - return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : message; - case ADAPTIVE: - return (message instanceof TextMessage) ? textToObject(session, (TextMessage)message) : (message instanceof ObjectMessage) ? objectToText(session, (ObjectMessage)message) : message; - default: - } - return message; - } - - public MessageTransform getTransformType() { - return transformType; - } - - public void setTransformType(MessageTransform transformType) { - this.transformType = transformType; - } - - /** - * Transforms an incoming XML encoded {@link TextMessage} to an - * {@link ObjectMessage} - * - * @param session - JMS session currently being used - * @param textMessage - text message to transform to object message - * @return ObjectMessage - * @throws JMSException - */ - protected ObjectMessage textToObject(Session session, TextMessage textMessage) throws JMSException { - Object object = unmarshall(session, textMessage); - if (object instanceof Serializable) { - ObjectMessage answer = session.createObjectMessage((Serializable)object); - copyProperties(textMessage, answer); - return answer; - } else { - throw new JMSException("Object is not serializable: " + object); - } - } - - /** - * Transforms an incoming {@link ObjectMessage} to an XML encoded - * {@link TextMessage} - * - * @param session - JMS session currently being used - * @param objectMessage - object message to transform to text message - * @return XML encoded TextMessage - * @throws JMSException - */ - protected TextMessage objectToText(Session session, ObjectMessage objectMessage) throws JMSException { - TextMessage answer = session.createTextMessage(marshall(session, objectMessage)); - copyProperties(objectMessage, answer); - return answer; - } - - /** - * Marshalls the Object in the {@link ObjectMessage} to a string using XML - * encoding - */ - protected abstract String marshall(Session session, ObjectMessage objectMessage) throws JMSException; - - /** - * Unmarshalls the XML encoded message in the {@link TextMessage} to an - * Object - */ - protected abstract Object unmarshall(Session session, TextMessage textMessage) throws JMSException; - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/OXMMessageTransformer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/** - * 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.util.oxm; - -import java.io.StringReader; -import java.io.StringWriter; -import javax.jms.JMSException; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.springframework.oxm.support.AbstractMarshaller; - - -/** - * Transforms object messages to text messages and vice versa using Spring OXM. - * - */ -public class OXMMessageTransformer extends AbstractXMLMessageTransformer { - - /** - * OXM marshaller used to marshall/unmarshall messages - */ - private AbstractMarshaller marshaller; - - public AbstractMarshaller getMarshaller() { - return marshaller; - } - - public void setMarshaller(AbstractMarshaller marshaller) { - this.marshaller = marshaller; - } - - /** - * Marshalls the Object in the {@link ObjectMessage} to a string using XML - * encoding - */ - protected String marshall(Session session, ObjectMessage objectMessage) - throws JMSException { - try { - StringWriter writer = new StringWriter(); - Result result = new StreamResult(writer); - marshaller.marshal(objectMessage.getObject(), result); - writer.flush(); - return writer.toString(); - } catch (Exception e) { - throw new JMSException(e.getMessage()); - } - } - - /** - * Unmarshalls the XML encoded message in the {@link TextMessage} to an - * Object - */ - protected Object unmarshall(Session session, TextMessage textMessage) - throws JMSException { - try { - String text = textMessage.getText(); - Source source = new StreamSource(new StringReader(text)); - return marshaller.unmarshal(source); - } catch (Exception e) { - throw new JMSException(e.getMessage()); - } - } - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java --- activemq-5.16.0/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/main/java/org/apache/activemq/util/oxm/XStreamMessageTransformer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -/** - * 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.util.oxm; - -import java.io.Serializable; -import java.io.StringReader; -import java.io.StringWriter; -import javax.jms.JMSException; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.HierarchicalStreamDriver; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.io.xml.PrettyPrintWriter; -import com.thoughtworks.xstream.io.xml.XppReader; - -import org.xmlpull.mxp1.MXParser; - -/** - * Transforms object messages to text messages and vice versa using - * {@link XStream} - * - */ -public class XStreamMessageTransformer extends AbstractXMLMessageTransformer { - - private XStream xStream; - - /** - * Specialized driver to be used with stream readers and writers - */ - private HierarchicalStreamDriver streamDriver; - - // Properties - // ------------------------------------------------------------------------- - public XStream getXStream() { - if (xStream == null) { - xStream = createXStream(); - } - return xStream; - } - - public void setXStream(XStream xStream) { - this.xStream = xStream; - } - - public HierarchicalStreamDriver getStreamDriver() { - return streamDriver; - } - - public void setStreamDriver(HierarchicalStreamDriver streamDriver) { - this.streamDriver = streamDriver; - } - - // Implementation methods - // ------------------------------------------------------------------------- - protected XStream createXStream() { - return new XStream(); - } - - /** - * Marshalls the Object in the {@link ObjectMessage} to a string using XML - * encoding - */ - protected String marshall(Session session, ObjectMessage objectMessage) throws JMSException { - Serializable object = objectMessage.getObject(); - StringWriter buffer = new StringWriter(); - HierarchicalStreamWriter out; - if (streamDriver != null) { - out = streamDriver.createWriter(buffer); - } else { - out = new PrettyPrintWriter(buffer); - } - getXStream().marshal(object, out); - return buffer.toString(); - } - - /** - * Unmarshalls the XML encoded message in the {@link TextMessage} to an - * Object - */ - protected Object unmarshall(Session session, TextMessage textMessage) throws JMSException { - HierarchicalStreamReader in; - if (streamDriver != null) { - in = streamDriver.createReader(new StringReader(textMessage.getText())); - } else { - in = new XppReader(new StringReader(textMessage.getText()), new MXParser()); - } - return getXStream().unmarshal(in); - } - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java --- activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/AbstractXMLMessageTransformerTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,237 +0,0 @@ -/** - * 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.util.oxm; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; - -import junit.framework.TestCase; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.ActiveMQMessageConsumer; -import org.apache.activemq.MessageTransformer; -import org.apache.activemq.util.xstream.SamplePojo; - -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.ADAPTIVE; -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.OBJECT; -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.XML; - -public abstract class AbstractXMLMessageTransformerTest extends TestCase { - protected ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); - protected Connection connection; - protected long timeout = 5000; - - protected Connection createConnection(MessageTransformer transformer) throws Exception { - connectionFactory.setTransformer(transformer); - connection = connectionFactory.createConnection(); - connection.start(); - return connection; - } - - protected abstract AbstractXMLMessageTransformer createTransformer(); - - public void testSendObjectMessageReceiveAsTextMessageAndObjectMessage() throws Exception { - AbstractXMLMessageTransformer transformer = createTransformer(); - transformer.setTransformType(XML); - connection = createConnection(transformer); - - // lets create the consumers - Session objectSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = objectSession.createTopic(getClass().getName()); - MessageConsumer objectConsumer = objectSession.createConsumer(destination); - - Session textSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer textConsumer = textSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)textConsumer).setTransformer(null); - - // send a message - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - ObjectMessage request = producerSession.createObjectMessage(new SamplePojo("James", "London")); - producer.send(request); - - // lets consume it as an object message - Message message = objectConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - ObjectMessage objectMessage = (ObjectMessage)message; - Object object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - SamplePojo body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // lets consume it as a text message - message = textConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - TextMessage textMessage = (TextMessage)message; - String text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - System.out.println("Received XML..."); - System.out.println(text); - } - - public void testSendTextMessageReceiveAsObjectMessageAndTextMessage() throws Exception { - AbstractXMLMessageTransformer transformer = createTransformer(); - transformer.setTransformType(OBJECT); - connection = createConnection(transformer); - - // lets create the consumers - Session textSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = textSession.createTopic(getClass().getName()); - MessageConsumer textConsumer = textSession.createConsumer(destination); - - Session objectSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer objectConsumer = objectSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)objectConsumer).setTransformer(null); - - // send a message - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - String xmlText = "" - + "James" - + "London" - + ""; - - TextMessage request = producerSession.createTextMessage(xmlText); - producer.send(request); - - Message message; - // lets consume it as a text message - message = textConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - TextMessage textMessage = (TextMessage)message; - String text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - - // lets consume it as an object message - message = objectConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - ObjectMessage objectMessage = (ObjectMessage)message; - Object object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - SamplePojo body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - } - - public void testAdaptiveTransform() throws Exception { - AbstractXMLMessageTransformer transformer = createTransformer(); - transformer.setTransformType(ADAPTIVE); - connection = createConnection(transformer); - - // lets create the consumers - Session adaptiveSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = adaptiveSession.createTopic(getClass().getName()); - MessageConsumer adaptiveConsumer = adaptiveSession.createConsumer(destination); - - Session origSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer origConsumer = origSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)origConsumer).setTransformer(null); - - // Create producer - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - Message message; - ObjectMessage objectMessage; - TextMessage textMessage; - SamplePojo body; - Object object; - String text; - - // Send a text message - String xmlText = "" - + "James" - + "London" - + ""; - - TextMessage txtRequest = producerSession.createTextMessage(xmlText); - producer.send(txtRequest); - - // lets consume it as a text message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - textMessage = (TextMessage)message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - - // lets consume it as an object message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - objectMessage = (ObjectMessage)message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // Send object message - ObjectMessage objRequest = producerSession.createObjectMessage(new SamplePojo("James", "London")); - producer.send(objRequest); - - // lets consume it as an object message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - objectMessage = (ObjectMessage)message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // lets consume it as a text message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - textMessage = (TextMessage)message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - System.out.println("Received XML..."); - System.out.println(text); - - } - - protected void tearDown() throws Exception { - if (connection != null) { - connection.close(); - } - } - - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java --- activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/OXMMessageTransformTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** - * 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.util.oxm; - -import org.springframework.oxm.xstream.XStreamMarshaller; - -public class OXMMessageTransformTest extends AbstractXMLMessageTransformerTest { - - protected AbstractXMLMessageTransformer createTransformer() { - OXMMessageTransformer transformer = new OXMMessageTransformer(); - transformer.setMarshaller(new XStreamMarshaller()); - return transformer; - } - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java --- activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/oxm/XStreamMessageTransformTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/** - * 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.util.oxm; - -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; - -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import org.apache.activemq.ActiveMQMessageConsumer; -import org.apache.activemq.util.xstream.SamplePojo; - -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.ADAPTIVE; - -public class XStreamMessageTransformTest extends - AbstractXMLMessageTransformerTest { - - protected AbstractXMLMessageTransformer createTransformer() { - return new XStreamMessageTransformer(); - } - - public void testStreamDriverTransform() throws Exception { - XStreamMessageTransformer transformer = (XStreamMessageTransformer) createTransformer(); - transformer.setTransformType(ADAPTIVE); - transformer.setStreamDriver(new JettisonMappedXmlDriver()); - connection = createConnection(transformer); - - // lets create the consumers - Session adaptiveSession = connection.createSession(false, - Session.AUTO_ACKNOWLEDGE); - Destination destination = adaptiveSession.createTopic(getClass() - .getName()); - MessageConsumer adaptiveConsumer = adaptiveSession - .createConsumer(destination); - - Session origSession = connection.createSession(false, - Session.AUTO_ACKNOWLEDGE); - MessageConsumer origConsumer = origSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer) origConsumer).setTransformer(null); - - // Create producer - Session producerSession = connection.createSession(false, - Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - Message message; - ObjectMessage objectMessage; - TextMessage textMessage; - SamplePojo body; - Object object; - String text; - - // Send a text message - String xmlText = "{\"org.apache.activemq.util.xstream.SamplePojo\":{\"name\":\"James\",\"city\":\"London\"}}"; - - TextMessage txtRequest = producerSession.createTextMessage(xmlText); - producer.send(txtRequest); - - // lets consume it as a text message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, - message instanceof TextMessage); - textMessage = (TextMessage) message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null - && text.length() > 0); - - // lets consume it as an object message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, - message instanceof ObjectMessage); - objectMessage = (ObjectMessage) message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, - object instanceof SamplePojo); - body = (SamplePojo) object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // Send object message - ObjectMessage objRequest = producerSession - .createObjectMessage(new SamplePojo("James", "London")); - producer.send(objRequest); - - // lets consume it as an object message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, - message instanceof ObjectMessage); - objectMessage = (ObjectMessage) message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, - object instanceof SamplePojo); - body = (SamplePojo) object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // lets consume it as a text message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, - message instanceof TextMessage); - textMessage = (TextMessage) message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null - && text.length() > 0); - System.out.println("Received JSON..."); - System.out.println(text); - - } - -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/SamplePojo.java activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/SamplePojo.java --- activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/SamplePojo.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/SamplePojo.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/** - * 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.util.xstream; - -import java.io.Serializable; - -/** - * - */ -public class SamplePojo implements Serializable { - private String name; - private String city; - - public SamplePojo() { - } - - public SamplePojo(String name, String city) { - this.name = name; - this.city = city; - } - - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/XStreamTransformTest.java activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/XStreamTransformTest.java --- activemq-5.16.0/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/XStreamTransformTest.java 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/test/java/org/apache/activemq/util/xstream/XStreamTransformTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,315 +0,0 @@ -/** - * 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.util.xstream; - -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Session; -import javax.jms.TextMessage; - -import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; -import junit.framework.TestCase; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.ActiveMQMessageConsumer; - -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.ADAPTIVE; -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.OBJECT; -import static org.apache.activemq.util.oxm.AbstractXMLMessageTransformer.MessageTransform.XML; - -/** - * - */ -public class XStreamTransformTest extends TestCase { - protected ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false&broker.useJmx=false"); - protected Connection connection; - protected long timeout = 5000; - - public void testSendObjectMessageReceiveAsTextMessageAndObjectMessage() throws Exception { - org.apache.activemq.util.oxm.XStreamMessageTransformer transformer = new org.apache.activemq.util.oxm.XStreamMessageTransformer(); - transformer.setTransformType(XML); - connectionFactory.setTransformer(transformer); - connection = connectionFactory.createConnection(); - connection.start(); - - // lets create the consumers - Session objectSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = objectSession.createTopic(getClass().getName()); - MessageConsumer objectConsumer = objectSession.createConsumer(destination); - - Session textSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer textConsumer = textSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)textConsumer).setTransformer(null); - - // send a message - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - ObjectMessage request = producerSession.createObjectMessage(new SamplePojo("James", "London")); - producer.send(request); - - // lets consume it as an object message - Message message = objectConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - ObjectMessage objectMessage = (ObjectMessage)message; - Object object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - SamplePojo body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // lets consume it as a text message - message = textConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - TextMessage textMessage = (TextMessage)message; - String text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - System.out.println("Received XML..."); - System.out.println(text); - } - - public void testSendTextMessageReceiveAsObjectMessageAndTextMessage() throws Exception { - org.apache.activemq.util.oxm.XStreamMessageTransformer transformer = new org.apache.activemq.util.oxm.XStreamMessageTransformer(); - transformer.setTransformType(OBJECT); - connectionFactory.setTransformer(transformer); - connection = connectionFactory.createConnection(); - connection.start(); - - // lets create the consumers - Session textSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = textSession.createTopic(getClass().getName()); - MessageConsumer textConsumer = textSession.createConsumer(destination); - - Session objectSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer objectConsumer = objectSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)objectConsumer).setTransformer(null); - - // send a message - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - String xmlText = "" - + "James" - + "London" - + ""; - - TextMessage request = producerSession.createTextMessage(xmlText); - producer.send(request); - - Message message; - // lets consume it as a text message - message = textConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - TextMessage textMessage = (TextMessage)message; - String text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - - // lets consume it as an object message - message = objectConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - ObjectMessage objectMessage = (ObjectMessage)message; - Object object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - SamplePojo body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - } - - public void testAdaptiveTransform() throws Exception { - org.apache.activemq.util.oxm.XStreamMessageTransformer transformer = new org.apache.activemq.util.oxm.XStreamMessageTransformer(); - transformer.setTransformType(ADAPTIVE); - connectionFactory.setTransformer(transformer); - connection = connectionFactory.createConnection(); - connection.start(); - - // lets create the consumers - Session adaptiveSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = adaptiveSession.createTopic(getClass().getName()); - MessageConsumer adaptiveConsumer = adaptiveSession.createConsumer(destination); - - Session origSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer origConsumer = origSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)origConsumer).setTransformer(null); - - // Create producer - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - Message message; - ObjectMessage objectMessage; - TextMessage textMessage; - SamplePojo body; - Object object; - String text; - - // Send a text message - String xmlText = "" - + "James" - + "London" - + ""; - - TextMessage txtRequest = producerSession.createTextMessage(xmlText); - producer.send(txtRequest); - - // lets consume it as a text message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - textMessage = (TextMessage)message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - - // lets consume it as an object message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - objectMessage = (ObjectMessage)message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // Send object message - ObjectMessage objRequest = producerSession.createObjectMessage(new SamplePojo("James", "London")); - producer.send(objRequest); - - // lets consume it as an object message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - objectMessage = (ObjectMessage)message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // lets consume it as a text message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - textMessage = (TextMessage)message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - System.out.println("Received XML..."); - System.out.println(text); - - } - - public void testStreamDriverTransform() throws Exception { - org.apache.activemq.util.oxm.XStreamMessageTransformer transformer = new org.apache.activemq.util.oxm.XStreamMessageTransformer(); - transformer.setTransformType(ADAPTIVE); - transformer.setStreamDriver(new JettisonMappedXmlDriver()); - connectionFactory.setTransformer(transformer); - connection = connectionFactory.createConnection(); - connection.start(); - - // lets create the consumers - Session adaptiveSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination destination = adaptiveSession.createTopic(getClass().getName()); - MessageConsumer adaptiveConsumer = adaptiveSession.createConsumer(destination); - - Session origSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer origConsumer = origSession.createConsumer(destination); - // lets clear the transformer on this consumer so we see the message as - // it really is - ((ActiveMQMessageConsumer)origConsumer).setTransformer(null); - - // Create producer - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = producerSession.createProducer(destination); - - Message message; - ObjectMessage objectMessage; - TextMessage textMessage; - SamplePojo body; - Object object; - String text; - - // Send a text message - String xmlText = "{\"org.apache.activemq.util.xstream.SamplePojo\":{\"name\":\"James\",\"city\":\"London\"}}"; - - TextMessage txtRequest = producerSession.createTextMessage(xmlText); - producer.send(txtRequest); - - // lets consume it as a text message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - textMessage = (TextMessage)message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - - // lets consume it as an object message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - objectMessage = (ObjectMessage)message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // Send object message - ObjectMessage objRequest = producerSession.createObjectMessage(new SamplePojo("James", "London")); - producer.send(objRequest); - - // lets consume it as an object message - message = adaptiveConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be an ObjectMessage but was: " + message, message instanceof ObjectMessage); - objectMessage = (ObjectMessage)message; - object = objectMessage.getObject(); - assertTrue("object payload of wrong type: " + object, object instanceof SamplePojo); - body = (SamplePojo)object; - assertEquals("name", "James", body.getName()); - assertEquals("city", "London", body.getCity()); - - // lets consume it as a text message - message = origConsumer.receive(timeout); - assertNotNull("Should have received a message!", message); - assertTrue("Should be a TextMessage but was: " + message, message instanceof TextMessage); - textMessage = (TextMessage)message; - text = textMessage.getText(); - assertTrue("Text should be non-empty!", text != null && text.length() > 0); - System.out.println("Received JSON..."); - System.out.println(text); - - } - - protected void tearDown() throws Exception { - if (connection != null) { - connection.close(); - } - } -} diff -Nru activemq-5.16.0/trash/activemq-optional/src/test/resources/log4j.properties activemq-5.16.1/trash/activemq-optional/src/test/resources/log4j.properties --- activemq-5.16.0/trash/activemq-optional/src/test/resources/log4j.properties 2020-06-25 05:26:13.000000000 +0000 +++ activemq-5.16.1/trash/activemq-optional/src/test/resources/log4j.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.spring=WARN -#log4j.logger.org.apache.activemq=DEBUG -#log4j.logger.org.eclipse.jetty.io.nio.ssl=DEBUG -#log4j.logger.org.apache.http=INFO - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true \ No newline at end of file