http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java index 8955221..22b4690 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/integration/ServletContextBindingRegistry.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.integration; -import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; - import javax.servlet.ServletContext; +import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; + public class ServletContextBindingRegistry implements BindingRegistry { private ServletContext servletContext;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java index e0dabc8..3068f8b 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/AcknowledgedQueueConsumer.java @@ -34,9 +34,9 @@ import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.util.Constants; import org.apache.activemq.artemis.rest.util.LinkStrategy; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; public class AcknowledgedQueueConsumer extends QueueConsumer { @@ -136,12 +136,10 @@ public class AcknowledgedQueueConsumer extends QueueConsumer { ack.acknowledge(); //System.out.println("Acknowledge message: " + ack.getMessage()); ack.getMessage().acknowledge(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } - } - else { + } else { ack.unacknowledge(); unacknowledge(); } @@ -179,22 +177,18 @@ public class AcknowledgedQueueConsumer extends QueueConsumer { try { createSession(); - } - catch (Exception e) { + } catch (Exception e) { shutdown(); throw new RuntimeException(e); - } - finally { + } finally { try { old.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } try { oldSession.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java index 3437a67..ce8b24b 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedHttpMessage.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.queue; -import org.apache.activemq.artemis.api.core.client.ClientMessage; - import javax.ws.rs.core.Response; +import org.apache.activemq.artemis.api.core.client.ClientMessage; + public class ConsumedHttpMessage extends ConsumedMessage { private byte[] data; @@ -36,8 +36,7 @@ public class ConsumedHttpMessage extends ConsumedMessage { if (size > 0) { data = new byte[size]; message.getBodyBuffer().readBytes(data); - } - else { + } else { data = new byte[0]; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java index 22b8f7f..d30248a 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedMessage.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.rest.queue; +import javax.ws.rs.core.Response; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.HttpHeaderProperty; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - -import javax.ws.rs.core.Response; +import org.apache.activemq.artemis.rest.HttpHeaderProperty; public abstract class ConsumedMessage { @@ -56,11 +56,9 @@ public abstract class ConsumedMessage { Boolean aBoolean = message.getBooleanProperty(POSTED_AS_HTTP_MESSAGE); if (aBoolean != null && aBoolean.booleanValue()) { return new ConsumedHttpMessage(message); - } - else if (message.getType() == Message.OBJECT_TYPE) { + } else if (message.getType() == Message.OBJECT_TYPE) { return new ConsumedObjectMessage(message, options); - } - else { + } else { throw new IllegalArgumentException("ClientMessage must be an HTTP message or an Object message: " + message + " type: " + message.getType()); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java index ddd7a81..2cd5f9f 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumedObjectMessage.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.rest.queue; +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; + import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; -import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; - public class ConsumedObjectMessage extends ConsumedMessage { protected Object readObject; @@ -52,8 +52,7 @@ public class ConsumedObjectMessage extends ConsumedMessage { ois.setBlackList(options.getDeserializationBlackList()); } readObject = ois.readObject(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java index 84dae83..0584972 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/ConsumersResource.java @@ -94,8 +94,7 @@ public class ConsumersResource implements TimeoutTask.Callback { shutdown(consumer); } return true; - } - else { + } else { return false; } } @@ -136,8 +135,7 @@ public class ConsumersResource implements TimeoutTask.Callback { if (autoAck) { consumer = createConsumer(selector); - } - else { + } else { attributes |= ACKNOWLEDGED; consumer = createAcknowledgedConsumer(selector); } @@ -150,18 +148,15 @@ public class ConsumersResource implements TimeoutTask.Callback { if (autoAck) { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/" + attributesSegment + "/" + consumer.getId(), "-1"); - } - else { + } else { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/" + attributesSegment + "/" + consumer.getId(), "-1"); } return builder.build(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); - } - finally { + } finally { } } @@ -210,13 +205,11 @@ public class ConsumersResource implements TimeoutTask.Callback { Acknowledgement ack = ackedConsumer.getAck(); if (ack == null || ack.wasSet()) { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); - } - else { + } else { ackedConsumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId()); } - } - else { + } else { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/attributes-" + attributes + "/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); } } @@ -242,8 +235,7 @@ public class ConsumersResource implements TimeoutTask.Callback { QueueConsumer tmp = new AcknowledgedQueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); - } - else { + } else { QueueConsumer tmp = new QueueConsumer(sessionFactory, destination, consumerId, serviceManager, null); consumer = addReconnectedConsumerToMap(consumerId, tmp); } @@ -256,8 +248,7 @@ public class ConsumersResource implements TimeoutTask.Callback { consumer = queueConsumers.putIfAbsent(consumerId, tmp); if (consumer != null) { tmp.shutdown(); - } - else { + } else { consumer = tmp; serviceManager.getTimeoutTask().add(this, consumer.getId()); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java index 93512d9..9b0eb1a 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/DestinationServiceManager.java @@ -17,8 +17,8 @@ package org.apache.activemq.artemis.rest.queue; import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ActiveMQClient; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; @@ -148,8 +148,7 @@ public abstract class DestinationServiceManager { if (sessionFactory == null) { try { sessionFactory = locator.createSessionFactory(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java index 8c74ea3..6f72d81 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessage.java @@ -38,8 +38,8 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientProducer; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.rest.util.HttpMessageHelper; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.util.HttpMessageHelper; import org.apache.activemq.artemis.utils.UUID; import org.apache.activemq.artemis.utils.UUIDGenerator; @@ -85,12 +85,10 @@ public class PostMessage { producer.send(message); ActiveMQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); - } - catch (Exception ex) { + } catch (Exception ex) { try { pooled.session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } addPooled(); throw ex; @@ -147,8 +145,7 @@ public class PostMessage { } try { publish(headers, body, dupId, isDurable, ttl, expiration, priority); - } - catch (Exception e) { + } catch (Exception e) { Response error = Response.serverError().entity("Problem posting message: " + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(e, error); } @@ -231,8 +228,7 @@ public class PostMessage { for (Pooled pooled : pool) { try { pooled.session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } } @@ -253,11 +249,9 @@ public class PostMessage { if (expiration != null) { message.setExpiration(expiration.longValue()); - } - else if (ttl != null) { + } else if (ttl != null) { message.setExpiration(System.currentTimeMillis() + ttl.longValue()); - } - else if (producerTimeToLive > 0) { + } else if (producerTimeToLive > 0) { message.setExpiration(System.currentTimeMillis() + producerTimeToLive); } if (priority != null) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java index ef0da88..e11881d 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageDupsOk.java @@ -16,11 +16,6 @@ */ package org.apache.activemq.artemis.rest.queue; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.api.core.client.ClientProducer; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - import javax.ws.rs.POST; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; @@ -31,6 +26,11 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import java.net.URI; +import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientProducer; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; + /** * Implements simple "create" link. Returns 201 with Location of created resource as per HTTP */ @@ -49,12 +49,10 @@ public class PostMessageDupsOk extends PostMessage { producer.send(message); ActiveMQRestLogger.LOGGER.debug("Sent message: " + message); pool.add(pooled); - } - catch (Exception ex) { + } catch (Exception ex) { try { pooled.session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } addPooled(); throw ex; @@ -77,8 +75,7 @@ public class PostMessageDupsOk extends PostMessage { isDurable = durable.booleanValue(); } publish(headers, body, isDurable, ttl, expiration, priority); - } - catch (Exception e) { + } catch (Exception e) { Response error = Response.serverError().entity("Problem posting message: " + e.getMessage()).type("text/plain").build(); throw new WebApplicationException(e, error); } @@ -88,4 +85,4 @@ public class PostMessageDupsOk extends PostMessage { serviceManager.getLinkStrategy().setLinkHeader(builder, "create-next", "create-next", next.toString(), "*/*"); return builder.build(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java index 9c3a88d..a0e3819 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/PostMessageNoDups.java @@ -16,13 +16,13 @@ */ package org.apache.activemq.artemis.rest.queue; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - import javax.ws.rs.POST; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; + /** * implements reliable "create", "create-next" pattern defined by REST-* Messaging specification */ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java index 1ebe786..d4e0f87 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueConsumer.java @@ -114,15 +114,13 @@ public class QueueConsumer { try { consumer.close(); ActiveMQRestLogger.LOGGER.debug("Closed consumer: " + consumer); - } - catch (Exception e) { + } catch (Exception e) { } try { session.close(); ActiveMQRestLogger.LOGGER.debug("Closed session: " + session); - } - catch (Exception e) { + } catch (Exception e) { } session = null; consumer = null; @@ -165,8 +163,7 @@ public class QueueConsumer { try { return pollWithIndex(wait, info, basePath, index); - } - finally { + } finally { ping(0); // ping again as we don't want wait time included in timeout. } } @@ -186,10 +183,8 @@ public class QueueConsumer { if (autoAck) message.acknowledge(); return response; - } - catch (Exception e) { - Response errorResponse = Response.serverError().entity(e.getMessage()) - .status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } catch (Exception e) { + Response errorResponse = Response.serverError().entity(e.getMessage()).status(Response.Status.INTERNAL_SERVER_ERROR).build(); return errorResponse; } } @@ -199,8 +194,7 @@ public class QueueConsumer { ActiveMQRestLogger.LOGGER.debug("Created session: " + session); if (selector == null) { consumer = session.createConsumer(destination); - } - else { + } else { consumer = session.createConsumer(destination, SelectorTranslator.convertToActiveMQFilterString(selector)); } ActiveMQRestLogger.LOGGER.debug("Created consumer: " + consumer); @@ -211,8 +205,7 @@ public class QueueConsumer { ClientMessage m = null; if (timeoutSecs <= 0) { m = consumer.receive(1); - } - else { + } else { m = consumer.receive(timeoutSecs * 1000); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java index 2a74a52..fe47680 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java @@ -32,14 +32,14 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; -import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; -import org.apache.activemq.artemis.rest.util.Constants; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQQueue; import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; +import org.apache.activemq.artemis.rest.util.Constants; import org.w3c.dom.Document; @Path(Constants.PATH_FOR_QUEUES) @@ -68,27 +68,22 @@ public class QueueDestinationsResource { if (!query.isExists()) { if (queue.getSelector() != null) { session.createQueue(queueName, queueName, queue.getSelector(), queue.isDurable()); - } - else { + } else { session.createQueue(queueName, queueName, queue.isDurable()); } - } - else { + } else { throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build()); } - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } URI uri = uriInfo.getRequestUriBuilder().path(queueName).build(); return Response.created(uri).build(); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof WebApplicationException) throw (WebApplicationException) e; throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build()); @@ -114,12 +109,10 @@ public class QueueDestinationsResource { boolean defaultDurable = queueSettings.isDurableSend() || query.isDurable(); queue = createQueueResource(queueName, defaultDurable, queueSettings.getConsumerSessionTimeoutSeconds(), queueSettings.isDuplicatesAllowed()); - } - finally { + } finally { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -151,8 +144,7 @@ public class QueueDestinationsResource { PostMessage sender = null; if (duplicates) { sender = new PostMessageDupsOk(); - } - else { + } else { sender = new PostMessageNoDups(); } sender.setServiceManager(manager); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java index 869c38f..74eec85 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueResource.java @@ -29,8 +29,8 @@ import javax.ws.rs.core.UriInfo; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.PushConsumerResource; public class QueueResource extends DestinationResource { @@ -165,14 +165,12 @@ public class QueueResource extends DestinationResource { try { SimpleString queueName = new SimpleString(destination); session.deleteQueue(queueName); - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java index 7779248..a606044 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueServiceManager.java @@ -22,8 +22,8 @@ import java.util.List; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.PushStore; import org.apache.activemq.artemis.rest.queue.push.FilePushStore; +import org.apache.activemq.artemis.rest.queue.push.PushStore; public class QueueServiceManager extends DestinationServiceManager { @@ -102,8 +102,7 @@ public class QueueServiceManager extends DestinationServiceManager { try { timeoutTask.stop(); sessionFactory.close(); - } - catch (Exception e) { + } catch (Exception e) { } } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java index b3dc1d5..b2a0868 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/ActiveMQPushStrategy.java @@ -68,8 +68,7 @@ public class ActiveMQPushStrategy extends UriTemplateStrategy { try { initialize(); initialized = true; - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Failed to initialize.", e); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java index 54d2b50..d788cef 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/FilePushStore.java @@ -49,8 +49,7 @@ public class FilePushStore implements PushStore { reg.setLoadedFrom(file); ActiveMQRestLogger.LOGGER.addingPushRegistration(reg.getId()); map.put(reg.getId(), reg); - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRestLogger.LOGGER.errorLoadingStore(e, file.getName()); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java index 023e3f0..9474ec8 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumer.java @@ -16,6 +16,9 @@ */ package org.apache.activemq.artemis.rest.queue.push; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientSession; @@ -25,9 +28,6 @@ import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; import org.apache.activemq.artemis.utils.SelectorTranslator; -import java.util.ArrayList; -import java.util.List; - public class PushConsumer { protected PushRegistration registration; @@ -71,12 +71,10 @@ public class PushConsumer { if (registration.getTarget().getClassName() != null) { Class clazz = Thread.currentThread().getContextClassLoader().loadClass(registration.getTarget().getClassName()); strategy = (PushStrategy) clazz.newInstance(); - } - else if (registration.getTarget().getRelationship() != null) { + } else if (registration.getTarget().getRelationship() != null) { if (registration.getTarget().getRelationship().equals("destination")) { strategy = new ActiveMQPushStrategy(); - } - else if (registration.getTarget().getRelationship().equals("template")) { + } else if (registration.getTarget().getRelationship().equals("template")) { strategy = new UriTemplateStrategy(); } } @@ -97,8 +95,7 @@ public class PushConsumer { if (registration.getSelector() != null) { consumer = session.createConsumer(destination, SelectorTranslator.convertToActiveMQFilterString(registration.getSelector())); - } - else { + } else { consumer = session.createConsumer(destination); } consumer.setMessageHandler(new PushConsumerMessageHandler(this, session)); @@ -116,8 +113,7 @@ public class PushConsumer { if (session != null) { session.close(); } - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } @@ -126,8 +122,7 @@ public class PushConsumer { if (strategy != null) { strategy.stop(); } - } - catch (Exception e) { + } catch (Exception e) { } } @@ -137,8 +132,7 @@ public class PushConsumer { if (registration.isDurable()) { store.update(registration); } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRestLogger.LOGGER.errorUpdatingStore(e); } stop(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java index 4ac2f80..8f38dee 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerMessageHandler.java @@ -39,8 +39,7 @@ public class PushConsumerMessageHandler implements MessageHandler { try { clientMessage.acknowledge(); ActiveMQRestLogger.LOGGER.debug(this + ": acknowledged " + clientMessage); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e.getMessage(), e); } @@ -52,16 +51,13 @@ public class PushConsumerMessageHandler implements MessageHandler { ActiveMQRestLogger.LOGGER.debug("Acknowledging: " + clientMessage.getMessageID()); session.commit(); return; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } - } - else { + } else { try { session.rollback(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e.getMessage(), e); } if (pushConsumer.getRegistration().isDisableOnFailure()) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java index ef183e5..859b22b 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushConsumerResource.java @@ -34,8 +34,8 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; public class PushConsumerResource { @@ -89,8 +89,7 @@ public class PushConsumerResource { if (registration.isDurable() && pushStore != null) { pushStore.add(registration); } - } - catch (Exception e) { + } catch (Exception e) { consumer.stop(); throw new WebApplicationException(e, Response.serverError().entity("Failed to start consumer.").type("text/plain").build()); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java index e053347..d3aae6d 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/PushStore.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.queue.push; -import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; - import java.util.List; +import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; + public interface PushStore { void add(PushRegistration reg) throws Exception; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java index 2df104b..727743a 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/UriStrategy.java @@ -19,9 +19,12 @@ package org.apache.activemq.artemis.rest.queue.push; import javax.ws.rs.core.UriBuilder; import java.io.IOException; +import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.push.xml.BasicAuth; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; +import org.apache.activemq.artemis.rest.queue.push.xml.XmlHttpHeader; import org.apache.activemq.artemis.rest.util.HttpMessageHelper; import org.apache.http.HttpException; import org.apache.http.HttpHost; @@ -41,9 +44,6 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpCoreContext; -import org.apache.activemq.artemis.api.core.client.ClientMessage; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; -import org.apache.activemq.artemis.rest.queue.push.xml.XmlHttpHeader; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor; @@ -140,16 +140,13 @@ public class UriStrategy implements PushStrategy { if (retryAfter != null) { wait = Long.parseLong(retryAfter) * 1000; } - } - else if (status == 307) { + } else if (status == 307) { uri = res.getLocation().toString(); wait = 0; - } - else if ((status >= 200 && status < 299) || status == 303 || status == 304) { + } else if ((status >= 200 && status < 299) || status == 303 || status == 304) { ActiveMQRestLogger.LOGGER.debug("Success"); return true; - } - else if (status >= 400) { + } else if (status >= 400) { switch (status) { case 400: // these usually mean the message you are trying to send is crap, let dead letter logic take over case 411: @@ -177,21 +174,18 @@ public class UriStrategy implements PushStrategy { break; } } - } - catch (Exception e) { + } catch (Exception e) { ActiveMQRestLogger.LOGGER.debug("failed to push message to " + uri, e); e.printStackTrace(); return false; - } - finally { + } finally { if (res != null) res.releaseConnection(); } try { if (wait > 0) Thread.sleep(wait); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { throw new RuntimeException("Interrupted"); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java index 037ad85..b599dc5 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/Authentication.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.rest.queue.push.xml; -import java.io.Serializable; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; @XmlRootElement @XmlAccessorType(XmlAccessType.PROPERTY) http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java index b44468f..97df082 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlHttpHeader.java @@ -16,13 +16,12 @@ */ package org.apache.activemq.artemis.rest.queue.push.xml; -import java.io.Serializable; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; +import java.io.Serializable; @XmlRootElement(name = "header") @XmlAccessorType(XmlAccessType.PROPERTY) http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java index 2cd4c09..7d2317b 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/push/xml/XmlLink.java @@ -16,12 +16,11 @@ */ package org.apache.activemq.artemis.rest.queue.push.xml; -import java.io.Serializable; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; @XmlRootElement(name = "link") @XmlAccessorType(XmlAccessType.PROPERTY) http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java index 1f5789f..997e977 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscription.java @@ -20,9 +20,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.PushStore; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.push.PushConsumer; +import org.apache.activemq.artemis.rest.queue.push.PushStore; import org.apache.activemq.artemis.rest.queue.push.xml.PushRegistration; public class PushSubscription extends PushConsumer { @@ -50,16 +50,13 @@ public class PushSubscription extends PushConsumer { session = factory.createSession(); session.deleteQueue(subscriptionName); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { ActiveMQRestLogger.LOGGER.errorDeletingSubscriberQueue(e); - } - finally { + } finally { try { if (session != null) session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java index 6027007..ce4e5d2 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/PushSubscriptionsResource.java @@ -16,14 +16,6 @@ */ package org.apache.activemq.artemis.rest.topic; -import org.apache.activemq.artemis.api.core.ActiveMQException; -import org.apache.activemq.artemis.api.core.SimpleString; -import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.queue.push.PushConsumer; -import org.apache.activemq.artemis.rest.ActiveMQRestLogger; - import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -39,6 +31,14 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; +import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; +import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.push.PushConsumer; + public class PushSubscriptionsResource { protected Map<String, PushSubscription> consumers = new ConcurrentHashMap<>(); @@ -78,13 +78,11 @@ public class PushSubscriptionsResource { if (durable) { session.createQueue(destination, subscriptionName, true); - } - else { + } else { session.createTemporaryQueue(destination, subscriptionName); } return session; - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } } @@ -102,12 +100,10 @@ public class PushSubscriptionsResource { PushSubscription consumer = new PushSubscription(sessionFactory, reg.getDestination(), reg.getId(), reg, pushStore, jmsOptions); try { consumer.start(); - } - catch (Exception e) { + } catch (Exception e) { consumer.stop(); throw new Exception("Failed starting push subscriber for " + destination + " of push subscriber: " + reg.getTarget(), e); - } - finally { + } finally { closeSession(createSession); closeSession(session); } @@ -120,8 +116,7 @@ public class PushSubscriptionsResource { if (createSession != null) { try { createSession.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -146,8 +141,7 @@ public class PushSubscriptionsResource { if (registration.isDurable() && pushStore != null) { pushStore.add(registration); } - } - catch (Exception e) { + } catch (Exception e) { consumer.stop(); throw new WebApplicationException(e, Response.serverError().entity("Failed to start consumer.").type("text/plain").build()); } @@ -156,8 +150,7 @@ public class PushSubscriptionsResource { UriBuilder location = uriInfo.getAbsolutePathBuilder(); location.path(genId); return Response.created(location.build()).build(); - } - finally { + } finally { closeSession(createSession); } } @@ -215,11 +208,9 @@ public class PushSubscriptionsResource { session = sessionFactory.createSession(); session.deleteQueue(subscriptionName); - } - catch (ActiveMQException e) { - } - finally { + } catch (ActiveMQException e) { + } finally { closeSession(session); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java index 56cbab4..f2c2390 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/SubscriptionsResource.java @@ -37,9 +37,9 @@ import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; -import org.apache.activemq.artemis.rest.queue.Acknowledgement; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; import org.apache.activemq.artemis.rest.queue.AcknowledgedQueueConsumer; +import org.apache.activemq.artemis.rest.queue.Acknowledgement; import org.apache.activemq.artemis.rest.queue.DestinationServiceManager; import org.apache.activemq.artemis.rest.queue.QueueConsumer; import org.apache.activemq.artemis.rest.util.TimeoutTask; @@ -98,8 +98,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { shutdown(consumer); } return true; - } - else { + } else { return false; } } @@ -172,15 +171,13 @@ public class SubscriptionsResource implements TimeoutTask.Callback { if (autoAck) { headAutoAckSubscriptionResponse(uriInfo, consumer, builder, pathToPullSubscriptions); consumer.setSessionLink(builder, uriInfo, pathToPullSubscriptions + "/auto-ack/" + consumer.getId()); - } - else { + } else { headAcknowledgedConsumerResponse(uriInfo, (AcknowledgedQueueConsumer) consumer, builder); consumer.setSessionLink(builder, uriInfo, pathToPullSubscriptions + "/acknowledged/" + consumer.getId()); } return builder.build(); } - } - else { + } else { subscriptionName = generateSubscriptionName(); } ClientSession session = null; @@ -191,8 +188,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { if (durable) { session.createQueue(destination, subscriptionName, true); - } - else { + } else { session.createTemporaryQueue(destination, subscriptionName); } } @@ -209,23 +205,19 @@ public class SubscriptionsResource implements TimeoutTask.Callback { Response.ResponseBuilder builder = Response.created(location.build()); if (autoAck) { QueueConsumer.setConsumeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/auto-ack/" + consumer.getId(), "-1"); - } - else { + } else { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(0) + "/acknowledged/" + consumer.getId(), "-1"); } return builder.build(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -243,8 +235,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { subscription.setDurable(durable); subscription.setDeleteWhenIdle(deleteWhenIdle); consumer = subscription; - } - else { + } else { AcknowledgedSubscriptionResource subscription = new AcknowledgedSubscriptionResource(sessionFactory, subscriptionName, subscriptionName, serviceManager, selector, durable, timeout); subscription.setDurable(durable); subscription.setDeleteWhenIdle(deleteWhenIdle); @@ -333,8 +324,7 @@ public class SubscriptionsResource implements TimeoutTask.Callback { Acknowledgement ack = consumer.getAck(); if (ack == null || ack.wasSet()) { AcknowledgedQueueConsumer.setAcknowledgeNextLink(serviceManager.getLinkStrategy(), builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/acknowledged/" + consumer.getId(), Long.toString(consumer.getConsumeIndex())); - } - else { + } else { consumer.setAcknowledgementLink(builder, uriInfo, uriInfo.getMatchedURIs().get(1) + "/acknowledged/" + consumer.getId()); } } @@ -356,16 +346,13 @@ public class SubscriptionsResource implements TimeoutTask.Callback { ClientSession.QueueQuery query = session.queueQuery(new SimpleString(subscriptionId)); return query.isExists(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); - } - finally { + } finally { if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -377,20 +364,17 @@ public class SubscriptionsResource implements TimeoutTask.Callback { QueueConsumer tmp = null; try { tmp = createConsumer(true, autoAck, subscriptionId, null, consumerTimeoutSeconds * 1000L, false); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { throw new RuntimeException(e); } consumer = queueConsumers.putIfAbsent(subscriptionId, tmp); if (consumer == null) { consumer = tmp; serviceManager.getTimeoutTask().add(this, subscriptionId); - } - else { + } else { tmp.shutdown(); } - } - else { + } else { throw new WebApplicationException(Response.status(405).entity("Failed to find subscriber " + subscriptionId + " you will have to reconnect").type("text/plain").build()); } return consumer; @@ -429,17 +413,14 @@ public class SubscriptionsResource implements TimeoutTask.Callback { session = sessionFactory.createSession(); session.deleteQueue(subscriptionName); - } - catch (ActiveMQException e) { - } - finally { + } catch (ActiveMQException e) { + } finally { if (session != null) { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java index bd3980c..af3e9c7 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java @@ -32,12 +32,12 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; -import org.apache.activemq.artemis.rest.queue.DestinationSettings; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.apache.activemq.artemis.jms.server.config.TopicConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.queue.DestinationSettings; import org.apache.activemq.artemis.rest.queue.PostMessage; import org.apache.activemq.artemis.rest.queue.PostMessageDupsOk; import org.apache.activemq.artemis.rest.queue.PostMessageNoDups; @@ -69,22 +69,18 @@ public class TopicDestinationsResource { if (!query.isExists()) { session.createQueue(topicName, topicName, "__AMQX=-1", true); - } - else { + } else { throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build()); } - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } URI uri = uriInfo.getRequestUriBuilder().path(topicName).build(); return Response.created(uri).build(); - } - catch (Exception e) { + } catch (Exception e) { if (e instanceof WebApplicationException) throw (WebApplicationException) e; throw new WebApplicationException(e, Response.serverError().type("text/plain").entity("Failed to create queue.").build()); @@ -106,12 +102,10 @@ public class TopicDestinationsResource { boolean defaultDurable = queueSettings.isDurableSend() || query.isDurable(); topic = createTopicResource(name, defaultDurable, queueSettings.getConsumerSessionTimeoutSeconds(), queueSettings.isDuplicatesAllowed()); - } - finally { + } finally { try { session.close(); - } - catch (ActiveMQException e) { + } catch (ActiveMQException e) { } } } @@ -145,8 +139,7 @@ public class TopicDestinationsResource { PostMessage sender = null; if (duplicates) { sender = new PostMessageDupsOk(); - } - else { + } else { sender = new PostMessageNoDups(); } sender.setDefaultDurable(defaultDurable); @@ -170,4 +163,4 @@ public class TopicDestinationsResource { topicResource.start(); return topicResource; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java index fd8f51a..3348ac6 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicPushStore.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.topic; -import org.apache.activemq.artemis.rest.queue.push.PushStore; - import java.util.List; +import org.apache.activemq.artemis.rest.queue.push.PushStore; + public interface TopicPushStore extends PushStore { List<PushTopicRegistration> getByTopic(String topic); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java index 85a8616..038bf86 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicResource.java @@ -158,20 +158,17 @@ public class TopicResource extends DestinationResource { try { stop(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } ClientSession session = serviceManager.getSessionFactory().createSession(false, false, false); try { SimpleString topicName = new SimpleString(destination); session.deleteQueue(topicName); - } - finally { + } finally { try { session.close(); - } - catch (Exception ignored) { + } catch (Exception ignored) { } } @@ -180,4 +177,4 @@ public class TopicResource extends DestinationResource { public void setTopicDestinationsResource(TopicDestinationsResource topicDestinationsResource) { this.topicDestinationsResource = topicDestinationsResource; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java index 7dbdd23..1b710ee 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicServiceManager.java @@ -16,14 +16,14 @@ */ package org.apache.activemq.artemis.rest.topic; +import java.util.ArrayList; +import java.util.List; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; import org.apache.activemq.artemis.rest.queue.DestinationServiceManager; -import java.util.ArrayList; -import java.util.List; - public class TopicServiceManager extends DestinationServiceManager { protected TopicPushStore pushStore; @@ -88,8 +88,7 @@ public class TopicServiceManager extends DestinationServiceManager { defaultDurable = topicDeployment.isDurableSend(); if (query.isExists()) { defaultDurable = query.isDurable(); - } - else { + } else { session.createQueue(queueName, queueName, topicDeployment.isDurableSend()); } } @@ -106,8 +105,7 @@ public class TopicServiceManager extends DestinationServiceManager { } try { sessionFactory.close(); - } - catch (Exception e) { + } catch (Exception e) { } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java index 18d9fb7..0f590c9 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/CustomHeaderLinkStrategy.java @@ -25,11 +25,9 @@ public class CustomHeaderLinkStrategy implements LinkStrategy { String headerName = null; if (title != null) { headerName = title; - } - else if (rel != null) { + } else if (rel != null) { headerName = rel; - } - else { + } else { throw new RuntimeException("Cannot figure out header name"); } headerName = "msg-" + headerName; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java index 7d97eef..05ca387 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/HttpMessageHelper.java @@ -16,20 +16,20 @@ */ package org.apache.activemq.artemis.rest.util; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MultivaluedMap; +import java.io.ByteArrayInputStream; +import java.util.List; +import java.util.Map.Entry; + import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; -import org.apache.activemq.artemis.rest.HttpHeaderProperty; import org.apache.activemq.artemis.rest.ActiveMQRestLogger; +import org.apache.activemq.artemis.rest.HttpHeaderProperty; import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; import org.jboss.resteasy.client.ClientRequest; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; -import java.io.ByteArrayInputStream; -import java.util.List; -import java.util.Map.Entry; - public class HttpMessageHelper { public static final String POSTED_AS_HTTP_MESSAGE = "postedAsHttpMessage"; @@ -39,7 +39,10 @@ public class HttpMessageHelper { return lowerKey.toLowerCase().startsWith("content") || lowerKey.toLowerCase().equals("link"); } - public static void buildMessage(ClientMessage message, ClientRequest request, String contentType, ConnectionFactoryOptions jmsOptions) { + public static void buildMessage(ClientMessage message, + ClientRequest request, + String contentType, + ConnectionFactoryOptions jmsOptions) { for (SimpleString key : message.getPropertyNames()) { String k = key.toString(); String headerName = HttpHeaderProperty.fromPropertyName(k); @@ -64,8 +67,7 @@ public class HttpMessageHelper { message.getBodyBuffer().readBytes(body); ActiveMQRestLogger.LOGGER.debug("Building Message from HTTP message"); request.body(contentType, body); - } - else { + } else { // assume posted as a JMS or ActiveMQ Artemis object message size = message.getBodyBuffer().readInt(); byte[] body = new byte[size]; @@ -81,8 +83,7 @@ public class HttpMessageHelper { obj = ois.readObject(); ActiveMQRestLogger.LOGGER.debug("**** Building Message from object: " + obj.toString()); request.body(contentType, obj); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java index ccc7fec..970d307 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/LinkHeaderLinkStrategy.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.util; -import org.jboss.resteasy.spi.Link; - import javax.ws.rs.core.Response; +import org.jboss.resteasy.spi.Link; + public class LinkHeaderLinkStrategy implements LinkStrategy { /** http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java index 233a533..e2b9cd5 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/util/TimeoutTask.java @@ -50,17 +50,14 @@ public class TimeoutTask implements Runnable { if (callbacksLock.tryLock()) { try { callbacks.put(token, callback); - } - finally { + } finally { callbacksLock.unlock(); } - } - else { + } else { pendingCallbacksLock.lock(); try { pendingCallbacks.put(token, callback); - } - finally { + } finally { pendingCallbacksLock.unlock(); } } @@ -70,8 +67,7 @@ public class TimeoutTask implements Runnable { callbacksLock.lock(); try { callbacks.remove(token); - } - finally { + } finally { callbacksLock.unlock(); } } @@ -101,8 +97,7 @@ public class TimeoutTask implements Runnable { while (running) { try { Thread.sleep(interval * 1000); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { running = false; break; } @@ -127,8 +122,7 @@ public class TimeoutTask implements Runnable { deadConsumers += 1; expiredCallbacks.put(token, callback); callbacks.remove(token); - } - else { + } else { liveConsumers += 1; } } @@ -144,12 +138,10 @@ public class TimeoutTask implements Runnable { callbacks.putAll(pendingCallbacks); pendingCallbacks.clear(); } - } - finally { + } finally { pendingCallbacksLock.unlock(); } - } - finally { + } finally { callbacksLock.unlock(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java index baf464f..1635a44 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/AutoAckTopicTest.java @@ -172,8 +172,7 @@ public class AutoAckTopicTest extends MessageTestBase { System.out.println("NPS response: " + response.getStatus()); Assert.assertEquals(201, response.getStatus()); isFinished = true; - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Exception " + e); failed = true; } @@ -207,8 +206,7 @@ public class AutoAckTopicTest extends MessageTestBase { ClientResponse<?> response = req.post(); response.releaseConnection(); isFinished = true; - } - catch (Exception e) { + } catch (Exception e) { failed = true; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java index 4a61d59..145ddec 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckQueueTest.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.artemis.rest.test; -import org.apache.activemq.artemis.rest.util.Constants; -import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.apache.activemq.artemis.rest.queue.QueueDeployment; +import org.apache.activemq.artemis.rest.util.Constants; import org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy; +import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; @@ -370,4 +370,4 @@ public class ClientAckQueueTest extends MessageTestBase { Assert.assertEquals(204, session.request().delete().getStatus()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java index c4a89f4..26c0b5c 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/ClientAckTopicTest.java @@ -18,8 +18,8 @@ package org.apache.activemq.artemis.rest.test; import org.apache.activemq.artemis.rest.topic.TopicDeployment; import org.apache.activemq.artemis.rest.util.Constants; -import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.apache.activemq.artemis.rest.util.CustomHeaderLinkStrategy; +import org.apache.activemq.artemis.rest.util.LinkHeaderLinkStrategy; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.spi.Link; @@ -312,4 +312,4 @@ public class ClientAckTopicTest extends MessageTestBase { res.releaseConnection(); Assert.assertEquals(204, res.getStatus()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java index cf4e81e..dea9c0e 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/EmbeddedTest.java @@ -86,8 +86,7 @@ public class EmbeddedTest { message.setObject(object); producer.send(message); - } - finally { + } finally { conn.close(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java index fbae1a5..c3228ad 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/JMSTest.java @@ -30,10 +30,10 @@ import java.io.Serializable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.activemq.artemis.rest.HttpHeaderProperty; -import org.apache.activemq.artemis.rest.Jms; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory; +import org.apache.activemq.artemis.rest.HttpHeaderProperty; +import org.apache.activemq.artemis.rest.Jms; import org.apache.activemq.artemis.rest.queue.QueueDeployment; import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; @@ -125,8 +125,7 @@ public class JMSTest extends MessageTestBase { message.setObject(object); producer.send(message); - } - finally { + } finally { conn.close(); } } @@ -142,8 +141,7 @@ public class JMSTest extends MessageTestBase { try { order = Jms.getEntity(message, Order.class); messageID = message.getJMSMessageID(); - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); } latch.countDown(); @@ -191,8 +189,7 @@ public class JMSTest extends MessageTestBase { Assert.assertEquals(order, Listener.order); Assert.assertNotNull(Listener.messageID); } - } - finally { + } finally { conn.close(); } } @@ -270,4 +267,4 @@ public class JMSTest extends MessageTestBase { Assert.assertNotNull(consumeNext); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java index 63491d3..e20f645 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/MessageTestBase.java @@ -37,8 +37,7 @@ public class MessageTestBase { static { try { executorField = BaseClientResponse.class.getDeclaredField("executor"); - } - catch (NoSuchFieldException e) { + } catch (NoSuchFieldException e) { throw new RuntimeException(e); } executorField.setAccessible(true); @@ -61,8 +60,7 @@ public class MessageTestBase { public static Link getLinkByTitle(LinkStrategy strategy, ClientResponse response, String title) { if (strategy instanceof LinkHeaderLinkStrategy) { return response.getLinkHeader().getLinkByTitle(title); - } - else { + } else { String headerName = "msg-" + title; String href = (String) response.getHeaders().getFirst(headerName); if (href == null) @@ -71,8 +69,7 @@ public class MessageTestBase { Link l = new Link(title, null, href, null, null); try { l.setExecutor((ClientExecutor) executorField.get(response)); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new RuntimeException(e); } return l; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java index bc15969..0eb3e2f 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushQueueConsumerTest.java @@ -125,8 +125,7 @@ public class PersistentPushQueueConsumerTest { Assert.assertEquals(204, res.getStatus()); manager.getQueueManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } @@ -194,8 +193,7 @@ public class PersistentPushQueueConsumerTest { response.releaseConnection(); manager.getQueueManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec48f9ed/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java ---------------------------------------------------------------------- diff --git a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java index 571bc92..00dc54e 100644 --- a/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java +++ b/artemis-rest/src/test/java/org/apache/activemq/artemis/rest/test/PersistentPushTopicConsumerTest.java @@ -138,8 +138,7 @@ public class PersistentPushTopicConsumerTest { Assert.assertFalse(query.isExists()); manager.getQueueManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } @@ -196,8 +195,7 @@ public class PersistentPushTopicConsumerTest { Assert.assertEquals("1", Receiver.subscriber2); manager.getTopicManager().getPushStore().removeAll(); - } - finally { + } finally { shutdown(); } } @@ -236,4 +234,4 @@ public class PersistentPushTopicConsumerTest { manager.getTopicManager().deploy(deployment); } -} \ No newline at end of file +}
