From e800236056d84261ca34a849d8767405724de298 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Thu, 13 Feb 2014 16:24:28 +0000 Subject: QPID-5551 : Remove redundant throws AMQException clauses git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1567971 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/server/consumer/Consumer.java | 2 +- .../qpid/server/consumer/ConsumerTarget.java | 4 +- .../server/exchange/DefaultExchangeRegistry.java | 42 +++++++++---------- .../server/exchange/ExchangeInUseException.java | 45 -------------------- .../qpid/server/exchange/ExchangeRegistry.java | 3 +- .../qpid/server/message/MessageInstance.java | 6 +-- .../apache/qpid/server/queue/QueueConsumer.java | 12 ++---- .../apache/qpid/server/queue/QueueEntryImpl.java | 4 +- .../apache/qpid/server/queue/SimpleAMQQueue.java | 19 +++------ .../apache/qpid/server/queue/SubFlushRunner.java | 4 -- .../apache/qpid/server/consumer/MockConsumer.java | 4 +- .../qpid/server/queue/MockMessageInstance.java | 4 +- .../qpid/server/queue/SimpleAMQQueueTestBase.java | 10 +---- .../qpid/server/queue/StandardQueueTest.java | 2 +- .../server/protocol/v0_10/ConsumerTarget_0_10.java | 2 +- .../protocol/v0_10/ServerSessionDelegate.java | 5 --- .../qpid/server/protocol/v0_8/AMQChannel.java | 48 ++++++++-------------- .../server/protocol/v0_8/AMQProtocolEngine.java | 1 - .../server/protocol/v0_8/ClientDeliveryMethod.java | 2 +- .../server/protocol/v0_8/ConsumerTarget_0_8.java | 9 ++-- .../v0_8/handler/BasicGetMethodHandler.java | 2 +- .../v0_8/handler/ExchangeDeleteHandler.java | 6 --- .../v0_8/output/ProtocolOutputConverter.java | 8 ++-- .../v0_8/output/ProtocolOutputConverterImpl.java | 10 +---- .../qpid/server/protocol/v0_8/AMQChannelTest.java | 2 +- .../protocol/v0_8/InternalTestProtocolSession.java | 8 ++-- .../server/protocol/v1_0/ConsumerTarget_1_0.java | 4 +- .../server/management/amqp/ManagementNode.java | 4 +- .../management/amqp/ManagementNodeConsumer.java | 10 +---- .../server/management/amqp/ManagementResponse.java | 4 +- 30 files changed, 85 insertions(+), 201 deletions(-) delete mode 100644 qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java (limited to 'qpid/java') diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java index e082d6eee4..76eb7e8c14 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/Consumer.java @@ -77,5 +77,5 @@ public interface Consumer String getName(); - void flush() throws AMQException; + void flush(); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java index 92579475ed..a32fd7fc59 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/consumer/ConsumerTarget.java @@ -49,13 +49,13 @@ public interface ConsumerTarget AMQSessionModel getSessionModel(); - void send(MessageInstance entry, boolean batch) throws AMQException; + void send(MessageInstance entry, boolean batch); void flushBatched(); void queueDeleted(); - void queueEmpty() throws AMQException; + void queueEmpty(); boolean allocateCredit(ServerMessage msg); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java index b54f995b5e..858aa224de 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/DefaultExchangeRegistry.java @@ -102,39 +102,37 @@ public class DefaultExchangeRegistry implements ExchangeRegistry return _defaultExchange; } - public void unregisterExchange(String name, boolean inUse) throws AMQException + public boolean unregisterExchange(String name, boolean inUse) throws AMQException { final Exchange exchange = _exchangeMap.get(name); - if (exchange == null) + if (exchange != null) { - throw new AMQException(AMQConstant.NOT_FOUND, "Unknown exchange " + name, null); - } - if (!_host.getSecurityManager().authoriseDelete(exchange)) - { - throw new AMQSecurityException(); - } - - // TODO: check inUse argument + if (!_host.getSecurityManager().authoriseDelete(exchange)) + { + throw new AMQSecurityException(); + } - Exchange e = _exchangeMap.remove(name); - if (e != null) - { - e.close(); + // TODO: check inUse argument - synchronized (_listeners) + Exchange e = _exchangeMap.remove(name); + // if it is null then it was removed by another thread at the same time, we can ignore + if (e != null) { - for(RegistryChangeListener listener : _listeners) + e.close(); + + synchronized (_listeners) { - listener.exchangeUnregistered(exchange); + for(RegistryChangeListener listener : _listeners) + { + listener.exchangeUnregistered(exchange); + } } - } + } } - else - { - throw new AMQException("Unknown exchange " + name); - } + return exchange != null; + } public Collection getExchanges() diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java deleted file mode 100644 index 42b58da07e..0000000000 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java +++ /dev/null @@ -1,45 +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.qpid.server.exchange; - -import org.apache.qpid.AMQException; - -/** - * ExchangeInUseRegistry indicates that an exchange cannot be unregistered because it is currently being used. - * - *

- *
CRC Card
Responsibilities Collaborations - *
Represents failure to unregister exchange that is in use. - *
- * - * @todo Not an AMQP exception as no status code. - * - * @todo This exception is not used. However, it is part of the ExchangeRegistry interface, and looks like code is - * going to need to be added to throw/deal with this. Alternatively ExchangeRegistries may be able to handle the - * issue internally. - */ -public class ExchangeInUseException extends AMQException -{ - public ExchangeInUseException(String exchangeName) - { - super("Exchange " + exchangeName + " is currently in use"); - } -} diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java index 7b4dbf925b..743c8eea3f 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java @@ -40,10 +40,9 @@ public interface ExchangeRegistry * Unregister an exchange * @param exchange name of the exchange to delete * @param ifUnused if true, do NOT delete the exchange if it is in use (has queues bound to it) - * @throws ExchangeInUseException when the exchange cannot be deleted because it is in use * @throws AMQException */ - void unregisterExchange(String exchange, boolean ifUnused) throws ExchangeInUseException, AMQException; + boolean unregisterExchange(String exchange, boolean ifUnused) throws AMQException; void clearAndUnregisterMbeans(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java index 49969ce3c1..0bdf83d981 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/message/MessageInstance.java @@ -21,9 +21,7 @@ package org.apache.qpid.server.message; -import org.apache.qpid.AMQException; import org.apache.qpid.server.filter.Filterable; -import org.apache.qpid.server.queue.QueueEntry; import org.apache.qpid.server.store.TransactionLogResource; import org.apache.qpid.server.consumer.Consumer; import org.apache.qpid.server.txn.ServerTransaction; @@ -65,7 +63,7 @@ public interface MessageInstance, C extends Consu boolean getDeliveredToConsumer(); - boolean expired() throws AMQException; + boolean expired(); boolean acquire(C sub); @@ -201,7 +199,7 @@ public interface MessageInstance, C extends Consu void release(); - boolean resend() throws AMQException; + boolean resend(); void delete(); diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java index 5c891797f5..bd4724db20 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumer.java @@ -241,7 +241,7 @@ class QueueConsumer, Q _target.restoreCredit(queueEntry.getMessage()); } - void queueEmpty() throws AMQException + void queueEmpty() { _target.queueEmpty(); } @@ -295,12 +295,12 @@ class QueueConsumer, Q @Override - public final void flush() throws AMQException + public final void flush() { getQueue().flushConsumer(this); } - boolean resend(final E entry) throws AMQException + boolean resend(final E entry) { return getQueue().resend(entry, this); } @@ -460,14 +460,10 @@ class QueueConsumer, Q return _deliveredCount.longValue(); } - final void send(final E entry, final boolean batch) throws AMQException + final void send(final E entry, final boolean batch) { _deliveredCount.incrementAndGet(); ServerMessage message = entry.getMessage(); - if(message == null) - { - throw new AMQException("message was null!"); - } _deliveredBytes.addAndGet(message.getSize()); _target.send(entry, batch); } diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java index ae5c560db0..433daedee9 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueEntryImpl.java @@ -158,7 +158,7 @@ public abstract class QueueEntryImpl, Q extends return _deliveredToConsumer; } - public boolean expired() throws AMQException + public boolean expired() { ServerMessage message = getMessage(); if(message != null) @@ -493,7 +493,7 @@ public abstract class QueueEntryImpl, Q extends } @Override - public boolean resend() throws AMQException + public boolean resend() { QueueConsumer sub = getDeliveredConsumer(); if(sub != null) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java index 4450a3ed0c..25b6cac712 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SimpleAMQQueue.java @@ -793,7 +793,6 @@ abstract class SimpleAMQQueue, Q extends SimpleA } private void deliverMessage(final QueueConsumer sub, final E entry, boolean batch) - throws AMQException { setLastSeenEntry(sub, entry); @@ -894,7 +893,7 @@ abstract class SimpleAMQQueue, Q extends SimpleA _dequeueCount.incrementAndGet(); } - public boolean resend(final E entry, final QueueConsumer consumer) throws AMQException + public boolean resend(final E entry, final QueueConsumer consumer) { /* TODO : This is wrong as the consumer may be suspended, we should instead change the state of the message entry to resend and move back the consumer pointer. */ @@ -1438,17 +1437,13 @@ abstract class SimpleAMQQueue, Q extends SimpleA } - void flushConsumer(QueueConsumer sub) throws AMQException + void flushConsumer(QueueConsumer sub) { - // Access control - if (!getVirtualHost().getSecurityManager().authoriseConsume(this)) - { - throw new AMQSecurityException("Permission denied: " + getName()); - } + flushConsumer(sub, Long.MAX_VALUE); } - boolean flushConsumer(QueueConsumer sub, long iterations) throws AMQException + boolean flushConsumer(QueueConsumer sub, long iterations) { boolean atTail = false; final boolean keepSendLockHeld = iterations <= SimpleAMQQueue.MAX_ASYNC_DELIVERIES; @@ -1524,9 +1519,8 @@ abstract class SimpleAMQQueue, Q extends SimpleA * @param sub the consumer * @param batch true if processing can be batched * @return true if we have completed all possible deliveries for this sub. - * @throws AMQException */ - private boolean attemptDelivery(QueueConsumer sub, boolean batch) throws AMQException + private boolean attemptDelivery(QueueConsumer sub, boolean batch) { boolean atTail = false; @@ -1569,7 +1563,7 @@ abstract class SimpleAMQQueue, Q extends SimpleA return atTail || !subActive; } - protected void advanceAllConsumers() throws AMQException + protected void advanceAllConsumers() { QueueConsumerList.ConsumerNodeIterator consumerNodeIterator = _consumerList.iterator(); while (consumerNodeIterator.advance()) @@ -1588,7 +1582,6 @@ abstract class SimpleAMQQueue, Q extends SimpleA } private E getNextAvailableEntry(final QueueConsumer sub) - throws AMQException { QueueContext context = sub.getQueueContext(); if(context != null) diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java index c30a48b03a..50af44fed4 100755 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/SubFlushRunner.java @@ -66,10 +66,6 @@ class SubFlushRunner implements Runnable CurrentActor.set(_sub.getLogActor()); complete = getQueue().flushConsumer(_sub, ITERATIONS); } - catch (AMQException e) - { - _logger.error("Exception during asynchronous delivery by " + toString(), e); - } catch (final TransportException transe) { final String errorMessage = "Problem during asynchronous delivery by " + toString(); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java index a9b99503ec..2401aaed23 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/consumer/MockConsumer.java @@ -153,7 +153,7 @@ public class MockConsumer implements ConsumerTarget { } - public void send(MessageInstance entry, boolean batch) throws AMQException + public void send(MessageInstance entry, boolean batch) { if (messages.contains(entry)) { @@ -205,7 +205,7 @@ public class MockConsumer implements ConsumerTarget } - public void queueEmpty() throws AMQException + public void queueEmpty() { } diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java index 386bb46044..8594ba19a3 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/MockMessageInstance.java @@ -71,7 +71,7 @@ public class MockMessageInstance implements MessageInstance, Q extends { QueueEntryImpl entry = (QueueEntryImpl) object; entry.setRedelivered(); - try - { - _consumer.resend(entry); - } - catch (AMQException e) - { - fail("Exception thrown: " + e.getMessage()); - } + _consumer.resend(entry); + } }); diff --git a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java index 27fac12ac0..58b3531897 100644 --- a/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java +++ b/qpid/java/broker-core/src/test/java/org/apache/qpid/server/queue/StandardQueueTest.java @@ -217,7 +217,7 @@ public class StandardQueueTest extends SimpleAMQQueueTestBase