diff options
| author | Rupert Smith <rupertlssmith@apache.org> | 2007-05-22 13:45:50 +0000 |
|---|---|---|
| committer | Rupert Smith <rupertlssmith@apache.org> | 2007-05-22 13:45:50 +0000 |
| commit | e9bed29d6775e0376a2192624f6b1ddcb442d3d3 (patch) | |
| tree | 12e3956e53ef0fb76efd4fa2b5e2a169e85e861f /java/broker | |
| parent | 92e00544516bb3dc046e36007e7526750019daa8 (diff) | |
| download | qpid-python-e9bed29d6775e0376a2192624f6b1ddcb442d3d3.tar.gz | |
Eliminated catch/rethrow where underlying cause was discarded. All causes now wrapped.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@540584 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker')
4 files changed, 71 insertions, 68 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java index 40462cf2bf..f2cc6e8bca 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java +++ b/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java @@ -48,6 +48,8 @@ import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.server.configuration.Configurator; import org.apache.qpid.server.configuration.VirtualHostConfiguration; +import org.apache.qpid.server.exception.InternalErrorException; +import org.apache.qpid.server.exception.QueueAlreadyExistsException; import org.apache.qpid.server.exchange.Exchange; import org.apache.qpid.server.exchange.ExchangeFactory; import org.apache.qpid.server.exchange.ExchangeRegistry; @@ -56,12 +58,10 @@ import org.apache.qpid.server.management.MBeanConstructor; import org.apache.qpid.server.management.MBeanDescription; import org.apache.qpid.server.management.ManagedBroker; import org.apache.qpid.server.management.ManagedObject; +import org.apache.qpid.server.messageStore.MessageStore; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.queue.QueueRegistry; -import org.apache.qpid.server.messageStore.MessageStore; import org.apache.qpid.server.virtualhost.VirtualHost; -import org.apache.qpid.server.exception.InternalErrorException; -import org.apache.qpid.server.exception.QueueAlreadyExistsException; /** * This MBean implements the broker management interface and exposes the @@ -113,8 +113,9 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr Exchange exchange = _exchangeRegistry.getExchange(new AMQShortString(exchangeName)); if (exchange == null) { - exchange = _exchangeFactory.createExchange(new AMQShortString(exchangeName), new AMQShortString(type), - durable, false, 0); + exchange = + _exchangeFactory.createExchange(new AMQShortString(exchangeName), new AMQShortString(type), durable, + false, 0); _exchangeRegistry.registerExchange(exchange); } else @@ -183,9 +184,12 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr try { _messageStore.createQueue(queue); - } catch (Exception e) + } + catch (Exception e) { - throw new JMException("problem creating queue " + queue.getName()); + JMException jme = new JMException("problem creating queue " + queue.getName()); + jme.initCause(e); + throw jme; } } @@ -200,9 +204,7 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr } catch (AMQException ex) { - JMException jme = new JMException(ex.getMessage()); - jme.initCause(ex); - throw new MBeanException(jme, "Error in creating queue " + queueName); + throw new MBeanException(ex, "Error in creating queue " + queueName); } } @@ -228,17 +230,16 @@ public class AMQBrokerManagerMBean extends AMQManagedObject implements ManagedBr try { queue.delete(); - if( queue.isDurable() ) + if (queue.isDurable()) { _messageStore.destroyQueue(queue); } } catch (Exception ex) { - ex.printStackTrace(); - JMException jme = new JMException(ex.getMessage()); - jme.initCause(ex); - throw new MBeanException(jme, "Error in deleting queue " + queueName); + /*ex.printStackTrace(); + JMException jme = new JMException(ex.getMessage());*/ + throw new MBeanException(ex, "Error in deleting queue " + queueName); } } diff --git a/java/broker/src/main/java/org/apache/qpid/server/messageStore/JDBCStore.java b/java/broker/src/main/java/org/apache/qpid/server/messageStore/JDBCStore.java index 44de0d3d98..55d34fb2f0 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/messageStore/JDBCStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/messageStore/JDBCStore.java @@ -181,7 +181,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot create Exchange: " + exchange); + throw new InternalErrorException("Cannot create Exchange: " + exchange, e); } finally { if (connection != null) @@ -195,7 +195,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot create Exchange: " + exchange); + throw new InternalErrorException("Cannot create Exchange: " + exchange, e); } } } @@ -223,7 +223,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot remove Exchange: " + exchange); + throw new InternalErrorException("Cannot remove Exchange: " + exchange, e); } finally { if (connection != null) @@ -237,7 +237,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot remove Exchange: " + exchange); + throw new InternalErrorException("Cannot remove Exchange: " + exchange, e); } } } @@ -274,7 +274,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot create Exchange: " + exchange); + throw new InternalErrorException("Cannot create Exchange: " + exchange, e); } finally { if (connection != null) @@ -288,7 +288,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot create Exchange: " + exchange); + throw new InternalErrorException("Cannot create Exchange: " + exchange, e); } } } @@ -316,7 +316,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot remove Exchange: " + exchange); + throw new InternalErrorException("Cannot remove Exchange: " + exchange, e); } finally { if (connection != null) @@ -330,7 +330,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot remove Exchange: " + exchange); + throw new InternalErrorException("Cannot remove Exchange: " + exchange, e); } } } @@ -364,7 +364,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot create Queue: " + queue); + throw new InternalErrorException("Cannot create Queue: " + queue, e); } finally { if (connection != null) @@ -378,7 +378,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot create Queue: " + queue); + throw new InternalErrorException("Cannot create Queue: " + queue, e); } } } @@ -404,7 +404,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot remove Queue: " + queue); + throw new InternalErrorException("Cannot remove Queue: " + queue, e); } finally { if (connection != null) @@ -418,7 +418,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot remove Queue: " + queue); + throw new InternalErrorException("Cannot remove Queue: " + queue, e); } } } @@ -441,7 +441,7 @@ public class JDBCStore implements MessageStore stage(connection, m); } catch (Exception e) { - throw new InternalErrorException("Cannot stage Message: " + m); + throw new InternalErrorException("Cannot stage Message: " + m, e); } finally { if (connection != null) @@ -455,7 +455,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot stage Message: " + m); + throw new InternalErrorException("Cannot stage Message: " + m, e); } } } @@ -481,7 +481,7 @@ public class JDBCStore implements MessageStore appendContent(connection, m, data, offset, size); } catch (Exception e) { - throw new InternalErrorException("Cannot stage Message: " + m); + throw new InternalErrorException("Cannot stage Message: " + m, e); } finally { if (connection != null) @@ -495,7 +495,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot stage Message: " + m); + throw new InternalErrorException("Cannot stage Message: " + m, e); } } } @@ -545,7 +545,7 @@ public class JDBCStore implements MessageStore return result; } catch (Exception e) { - throw new InternalErrorException("Cannot load Message: " + m); + throw new InternalErrorException("Cannot load Message: " + m, e); } finally { if (connection != null) @@ -559,7 +559,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot load Message: " + m); + throw new InternalErrorException("Cannot load Message: " + m, e); } } } @@ -577,7 +577,7 @@ public class JDBCStore implements MessageStore destroy(connection, m); } catch (Exception e) { - throw new InternalErrorException("Cannot destroy message: " + m); + throw new InternalErrorException("Cannot destroy message: " + m, e); } finally { if (connection != null) @@ -591,7 +591,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot destroy message: " + m); + throw new InternalErrorException("Cannot destroy message: " + m, e); } } } @@ -644,7 +644,7 @@ public class JDBCStore implements MessageStore queue.enqueue(m); } catch (Exception e) { - throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue); + throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue, e); } finally { if (tx == null && connection != null) @@ -658,7 +658,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue); + throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue, e); } } } @@ -710,7 +710,7 @@ public class JDBCStore implements MessageStore queue.dequeue(m); } catch (Exception e) { - throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue); + throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue, e); } finally { if (tx == null && connection != null) @@ -724,7 +724,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue); + throw new InternalErrorException("Cannot enqueue message : " + m + " in queue: " + queue, e); } } } @@ -762,7 +762,7 @@ public class JDBCStore implements MessageStore return result; } catch (Exception e) { - throw new InternalErrorException("Cannot get all queues"); + throw new InternalErrorException("Cannot get all queues", e); } finally { if (connection != null) @@ -776,7 +776,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot get all queues"); + throw new InternalErrorException("Cannot get all queues", e); } } } @@ -793,7 +793,7 @@ public class JDBCStore implements MessageStore return getAllMessages(connection, queue); } catch (Exception e) { - throw new InternalErrorException("Cannot get all queues"); + throw new InternalErrorException("Cannot get all queues", e); } finally { if (connection != null) @@ -807,7 +807,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot get all queues"); + throw new InternalErrorException("Cannot get all queues", e); } } } @@ -922,7 +922,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot commit connection ="); + throw new InternalErrorException("Cannot commit connection =", e); } } @@ -939,7 +939,7 @@ public class JDBCStore implements MessageStore // we did not manage to rollback this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot rollback connection"); + throw new InternalErrorException("Cannot rollback connection", e); } } @@ -1029,7 +1029,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot save record: " + record); + throw new InternalErrorException("Cannot save record: " + record, e); } } @@ -1053,7 +1053,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot save xid: " + xid); + throw new InternalErrorException("Cannot save xid: " + xid, e); } } @@ -1074,7 +1074,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot delete record: " + tx.getXidID()); + throw new InternalErrorException("Cannot delete record: " + tx.getXidID(), e); } } @@ -1095,7 +1095,7 @@ public class JDBCStore implements MessageStore pstmt.executeUpdate(); } catch (Exception e) { - throw new InternalErrorException("Cannot delete xid: " + tx.getXidID()); + throw new InternalErrorException("Cannot delete xid: " + tx.getXidID(), e); } } @@ -1212,7 +1212,7 @@ public class JDBCStore implements MessageStore return result; } catch (Exception e) { - throw new InternalErrorException("Cannot get MessagePublishInfo of message: " + m); + throw new InternalErrorException("Cannot get MessagePublishInfo of message: " + m, e); } finally { if (connection != null) @@ -1226,7 +1226,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot get MessagePublishInfo of message: " + m); + throw new InternalErrorException("Cannot get MessagePublishInfo of message: " + m, e); } } } @@ -1261,7 +1261,7 @@ public class JDBCStore implements MessageStore return result; } catch (Exception e) { - throw new InternalErrorException("Cannot get Content Header of message: " + m); + throw new InternalErrorException("Cannot get Content Header of message: " + m, e); } finally { if (connection != null) @@ -1275,7 +1275,7 @@ public class JDBCStore implements MessageStore // we did not manage to commit this connection // it is better to release it _connectionPool.releaseDeadInstance(); - throw new InternalErrorException("Cannot get Content Header of message: " + m); + throw new InternalErrorException("Cannot get Content Header of message: " + m, e); } } } diff --git a/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/ConfigurationFilePrincipalDatabaseManager.java b/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/ConfigurationFilePrincipalDatabaseManager.java index 2d3f5e5131..2e506b9751 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/ConfigurationFilePrincipalDatabaseManager.java +++ b/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/ConfigurationFilePrincipalDatabaseManager.java @@ -27,20 +27,20 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.management.JMException; + import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.log4j.Logger; -import org.apache.qpid.configuration.PropertyUtils; +import org.apache.qpid.AMQException; import org.apache.qpid.configuration.PropertyException; +import org.apache.qpid.configuration.PropertyUtils; import org.apache.qpid.server.registry.ApplicationRegistry; +import org.apache.qpid.server.security.access.AMQUserManagementMBean; import org.apache.qpid.server.security.auth.database.PrincipalDatabase; import org.apache.qpid.server.security.auth.database.PrincipalDatabaseManager; -import org.apache.qpid.server.security.access.AMQUserManagementMBean; -import org.apache.qpid.AMQException; - -import javax.management.JMException; public class ConfigurationFilePrincipalDatabaseManager implements PrincipalDatabaseManager { @@ -107,7 +107,7 @@ public class ConfigurationFilePrincipalDatabaseManager implements PrincipalDatab } private void initialisePrincipalDatabase(PrincipalDatabase principalDatabase, Configuration config, int index) - throws FileNotFoundException, ConfigurationException + throws FileNotFoundException, ConfigurationException { String baseName = _base + "(" + index + ").attributes.attribute."; List<String> argumentNames = config.getList(baseName + "name"); @@ -139,9 +139,9 @@ public class ConfigurationFilePrincipalDatabaseManager implements PrincipalDatab if (method == null) { throw new ConfigurationException("No method " + methodName + " found in class " - + principalDatabase.getClass() - + " hence unable to configure principal database. The method must be public and " - + "have a single String argument with a void return type"); + + principalDatabase.getClass() + + " hence unable to configure principal database. The method must be public and " + + "have a single String argument with a void return type"); } try @@ -152,7 +152,7 @@ public class ConfigurationFilePrincipalDatabaseManager implements PrincipalDatab { if (ite instanceof ConfigurationException) { - throw(ConfigurationException) ite; + throw (ConfigurationException) ite; } else { @@ -178,7 +178,8 @@ public class ConfigurationFilePrincipalDatabaseManager implements PrincipalDatab if (principalDBs.size() == 0) { - throw new ConfigurationException("No principal-database specified for jmx security(" + baseSecurity + ".principal-database)"); + throw new ConfigurationException("No principal-database specified for jmx security(" + baseSecurity + + ".principal-database)"); } String databaseName = principalDBs.get(0); @@ -196,18 +197,19 @@ public class ConfigurationFilePrincipalDatabaseManager implements PrincipalDatab if (jmxaccesslist.size() == 0) { - throw new ConfigurationException("No access control files specified for jmx security(" + baseSecurity + ".access)"); + throw new ConfigurationException("No access control files specified for jmx security(" + baseSecurity + + ".access)"); } String jmxaccesssFile = null; - + try { jmxaccesssFile = PropertyUtils.replaceProperties(jmxaccesslist.get(0)); } catch (PropertyException e) { - throw new ConfigurationException("Unable to parse access control filename '" + jmxaccesssFile + "'"); + throw new ConfigurationException("Unable to parse access control filename '" + jmxaccesssFile + "'", e); } try diff --git a/java/broker/src/main/java/org/apache/qpid/server/txn/JDBCTransactionManager.java b/java/broker/src/main/java/org/apache/qpid/server/txn/JDBCTransactionManager.java index e60fb89bf7..0ea531630d 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/txn/JDBCTransactionManager.java +++ b/java/broker/src/main/java/org/apache/qpid/server/txn/JDBCTransactionManager.java @@ -191,7 +191,7 @@ public class JDBCTransactionManager implements TransactionManager } catch (Exception e) { _log.error("Cannot prepare tx: " + xid); - throw new InternalErrorException("Cannot prepare tx: " + xid); + throw new InternalErrorException("Cannot prepare tx: " + xid, e); } tx.prepare(); } |
