You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/01/14 00:04:13 UTC
[2/3] activemq-artemis git commit:
https://issues.apache.org/jira/browse/ARTEMIS-345 fixing URI for inVM
throwing a log.warn
https://issues.apache.org/jira/browse/ARTEMIS-345 fixing URI for inVM throwing a log.warn
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/dddd0a1e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/dddd0a1e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/dddd0a1e
Branch: refs/heads/master
Commit: dddd0a1efe13953719250e48a811778051638333
Parents: 23aa933
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Jan 13 16:38:38 2016 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Jan 13 17:48:23 2016 -0500
----------------------------------------------------------------------
...uentPropertyBeanIntrospectorWithIgnores.java | 81 ++++++++++++++++++++
.../activemq/artemis/utils/uri/URISchema.java | 3 +-
.../core/client/impl/ServerLocatorImpl.java | 6 ++
.../tests/integration/client/ConsumerTest.java | 21 +++++
4 files changed, 109 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dddd0a1e/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java
new file mode 100644
index 0000000..d0e70f4
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java
@@ -0,0 +1,81 @@
+/**
+ * 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.artemis.utils.uri;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.Locale;
+
+import org.apache.activemq.artemis.api.core.Pair;
+import org.apache.activemq.artemis.utils.ConcurrentHashSet;
+import org.apache.commons.beanutils.FluentPropertyBeanIntrospector;
+import org.apache.commons.beanutils.IntrospectionContext;
+import org.jboss.logging.Logger;
+
+public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBeanIntrospector {
+ static Logger logger = Logger.getLogger(FluentPropertyBeanIntrospectorWithIgnores.class);
+
+ private static ConcurrentHashSet<Pair<String, String>> ignores = new ConcurrentHashSet<>();
+
+ public static void addIgnore(String className, String propertyName) {
+ logger.trace("Adding ignore on " + className + "/" + propertyName);
+ ignores.add(new Pair<>(className, propertyName));
+ }
+
+ public static boolean isIgnored(String className, String propertyName) {
+ return ignores.contains(new Pair<>(className, propertyName));
+ }
+
+ @Override
+ public void introspect(IntrospectionContext icontext) throws IntrospectionException {
+ for (Method m : icontext.getTargetClass().getMethods()) {
+ if (m.getName().startsWith(getWriteMethodPrefix())) {
+ String propertyName = propertyName(m);
+ PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName);
+
+ if (isIgnored(icontext.getTargetClass().getName(), m.getName())) {
+ logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName());
+ continue;
+ }
+ try {
+ if (pd == null) {
+ icontext.addPropertyDescriptor(createFluentPropertyDescritor(m, propertyName));
+ }
+ else if (pd.getWriteMethod() == null) {
+ pd.setWriteMethod(m);
+ }
+ }
+ catch (IntrospectionException e) {
+ logger.debug(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ private PropertyDescriptor createFluentPropertyDescritor(Method m,
+ String propertyName) throws IntrospectionException {
+ return new PropertyDescriptor(propertyName(m), null, m);
+ }
+
+ private String propertyName(Method m) {
+ String methodName = m.getName().substring(getWriteMethodPrefix().length());
+ return (methodName.length() > 1) ? Character.toLowerCase(methodName.charAt(0)) + methodName.substring(1) : methodName.toLowerCase(Locale.ENGLISH);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dddd0a1e/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
index b76ceb1..9ee206b 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
@@ -27,7 +27,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.beanutils.BeanUtilsBean;
-import org.apache.commons.beanutils.FluentPropertyBeanIntrospector;
public abstract class URISchema<T, P> {
@@ -102,7 +101,7 @@ public abstract class URISchema<T, P> {
static {
// This is to customize the BeanUtils to use Fluent Proeprties as well
- beanUtils.getPropertyUtils().addBeanIntrospector(new FluentPropertyBeanIntrospector());
+ beanUtils.getPropertyUtils().addBeanIntrospector(new FluentPropertyBeanIntrospectorWithIgnores());
}
public static Map<String, String> parseQuery(String uri,
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dddd0a1e/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
index 77e1e66..59a4c78 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
@@ -66,6 +66,7 @@ import org.apache.activemq.artemis.uri.ServerLocatorParser;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
import org.apache.activemq.artemis.utils.ClassloadingUtil;
import org.apache.activemq.artemis.utils.UUIDGenerator;
+import org.apache.activemq.artemis.utils.uri.FluentPropertyBeanIntrospectorWithIgnores;
/**
* This is the implementation of {@link org.apache.activemq.artemis.api.core.client.ServerLocator} and all
@@ -77,6 +78,11 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
INITIALIZED, CLOSED, CLOSING
}
+ static {
+ // this is not really a property, needs to be ignored
+ FluentPropertyBeanIntrospectorWithIgnores.addIgnore(ServerLocatorImpl.class.getName(), "setThreadPools");
+ }
+
private static final long serialVersionUID = -1615857864410205260L;
// This is the default value
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/dddd0a1e/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
index 3be464e..e9918fc 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java
@@ -34,6 +34,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.MessageHandler;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
@@ -551,6 +552,26 @@ public class ConsumerTest extends ActiveMQTestBase {
// https://jira.jboss.org/jira/browse/HORNETQ-111
// Test that, on rollback credits are released for messages cleared in the buffer
@Test
+ public void testInVMURI() throws Exception {
+ locator.close();
+ ServerLocator locator = addServerLocator(ServerLocatorImpl.newLocator("vm:/1"));
+ ClientSessionFactory factory = locator.createSessionFactory();
+ ClientSession session = factory.createSession();
+ session.createQueue(QUEUE, QUEUE);
+ ClientProducer producer = session.createProducer(QUEUE);
+ producer.send(session.createMessage(true));
+
+ ClientConsumer consumer = session.createConsumer(QUEUE);
+ session.start();
+ Assert.assertNotNull(consumer.receiveImmediate());
+ session.close();
+ factory.close();
+
+ }
+
+ // https://jira.jboss.org/jira/browse/HORNETQ-111
+ // Test that, on rollback credits are released for messages cleared in the buffer
+ @Test
public void testConsumerCreditsOnRollbackLargeMessages() throws Exception {
locator.setConsumerWindowSize(10000).setMinLargeMessageSize(1000);