diff options
17 files changed, 81 insertions, 47 deletions
diff --git a/java/broker-plugins/experimental/slowconsumerdetection/src/test/java/org/apache/qpid/systest/SlowConsumerTest.java b/java/broker-plugins/experimental/slowconsumerdetection/src/test/java/org/apache/qpid/systest/SlowConsumerTest.java index d5b2b1858b..0789367320 100644 --- a/java/broker-plugins/experimental/slowconsumerdetection/src/test/java/org/apache/qpid/systest/SlowConsumerTest.java +++ b/java/broker-plugins/experimental/slowconsumerdetection/src/test/java/org/apache/qpid/systest/SlowConsumerTest.java @@ -154,6 +154,7 @@ public class SlowConsumerTest extends QpidTestCase implements ExceptionListener { JMSException jmsException = new JMSException(amqe.getMessage()); jmsException.setLinkedException(amqe); + jmsException.initCause(amqe); _connectionException = jmsException; } } diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 653e049002..f8e18f80ee 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -1077,6 +1077,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect _logger.error("error:", e); JMSException jmse = new JMSException("Error closing connection: " + e); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } } @@ -1391,9 +1392,7 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect if (code != null) { - je = - new JMSException(Integer.toString(code.getCode()), "Exception thrown against " + toString() + ": " - + cause); + je = new JMSException(Integer.toString(code.getCode()), "Exception thrown against " + toString() + ": " + cause); } else { @@ -1416,6 +1415,8 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect { je.setLinkedException((Exception) cause); } + + je.initCause(cause); } boolean closer = false; diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 32c7bb33b0..8f67274f53 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -265,6 +265,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } JMSException ex = new JMSException(exc.getMessage(), code); + ex.setLinkedException(exc); ex.initCause(exc); listener.onException(ex); } diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java index a8fcdf561c..9cee4dab53 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java @@ -168,6 +168,7 @@ public class AMQConnectionDelegate_8_0 implements AMQConnectionDelegate { JMSException jmse = new JMSException("Error creating session: " + e); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } finally diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java index 2d6f4434fe..ec4c668d7e 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java @@ -285,6 +285,7 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF { JMSException jmse = new JMSException("Error creating connection: " + e.getMessage()); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } @@ -324,6 +325,7 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF { JMSException jmse = new JMSException("Error creating connection: " + e.getMessage()); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } } @@ -461,6 +463,7 @@ public class AMQConnectionFactory implements ConnectionFactory, QueueConnectionF { JMSException jmse = new JMSException("Error creating connection: " + e.getMessage()); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } } diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java index 8e04dc9cbb..b80178baf9 100644 --- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java +++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java @@ -539,6 +539,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic if (manager.getCurrentState().equals(AMQState.CONNECTION_CLOSED) && manager.getLastException() != null) { ise.setLinkedException(manager.getLastException()); + ise.initCause(ise.getLinkedException()); } throw ise; @@ -702,6 +703,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic { JMSException jmse = new JMSException("Error closing session: " + e); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } // This is ignored because the channel is already marked as closed so the fail-over process will @@ -1087,7 +1089,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic _logger.error("", urlse); JMSException jmse = new JMSException(urlse.getReason()); jmse.setLinkedException(urlse); - + jmse.initCause(urlse); throw jmse; } } @@ -1297,9 +1299,10 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic } catch (Exception e) { - JMSException ex = new JMSException("Cannot create temporary queue"); - ex.setLinkedException(e); - throw ex; + JMSException jmse = new JMSException("Cannot create temporary queue"); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } @@ -1352,7 +1355,7 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic { JMSException jmse = new JMSException(urlse.getReason()); jmse.setLinkedException(urlse); - + jmse.initCause(urlse); throw jmse; } } @@ -1807,16 +1810,17 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic } catch (AMQInvalidArgumentException ise) { - JMSException ex = new InvalidSelectorException(ise.getMessage()); - ex.setLinkedException(ise); - throw ex; + JMSException jmse = new InvalidSelectorException(ise.getMessage()); + jmse.setLinkedException(ise); + jmse.initCause(ise); + throw jmse; } catch (AMQInvalidRoutingKeyException e) { - JMSException ide = - new InvalidDestinationException("Invalid routing key:" + amqd.getRoutingKey().toString()); - ide.setLinkedException(e); - throw ide; + JMSException jmse = new InvalidDestinationException("Invalid routing key:" + amqd.getRoutingKey().toString()); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } catch (AMQException e) { @@ -1826,8 +1830,8 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic } JMSException ex = new JMSException("Error registering consumer: " + e); - ex.setLinkedException(e); + ex.initCause(e); throw ex; } diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java index a1e94aaadd..73987d8b75 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java @@ -510,6 +510,7 @@ public abstract class BasicMessageConsumer<U> extends Closeable implements Messa if (o instanceof Throwable) { JMSException e = new JMSException("Message consumer forcibly closed due to error: " + o); + e.initCause((Throwable) o); if (o instanceof Exception) { e.setLinkedException((Exception) o); diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java index 045cb24454..c01439792a 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_10.java @@ -210,11 +210,12 @@ public class BasicMessageProducer_0_10 extends BasicMessageProducer } - catch (RuntimeException rte) + catch (RuntimeException e) { - JMSException ex = new JMSException("Exception when sending message"); - ex.initCause(rte); - throw ex; + JMSException jmse = new JMSException("Exception when sending message"); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } diff --git a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java index f726cd02a2..b770a8b524 100644 --- a/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java +++ b/java/client/src/main/java/org/apache/qpid/client/BasicMessageProducer_0_8.java @@ -162,9 +162,10 @@ public class BasicMessageProducer_0_8 extends BasicMessageProducer } catch (InterruptedException e) { - JMSException jmsEx = new JMSException("Interrupted while waiting for flow control to be removed"); - jmsEx.setLinkedException(e); - throw jmsEx; + JMSException jmse = new JMSException("Interrupted while waiting for flow control to be removed"); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } _protocolHandler.writeFrame(compositeFrame, wait); diff --git a/java/client/src/main/java/org/apache/qpid/client/JMSAMQException.java b/java/client/src/main/java/org/apache/qpid/client/JMSAMQException.java index 0927ca3625..1151a97cf4 100644 --- a/java/client/src/main/java/org/apache/qpid/client/JMSAMQException.java +++ b/java/client/src/main/java/org/apache/qpid/client/JMSAMQException.java @@ -49,17 +49,19 @@ public class JMSAMQException extends JMSException if (cause != null) { setLinkedException(cause); + initCause(cause); } } /** - * @param s The underlying exception. + * @param cause The underlying exception. * * @deprecated Use the other constructor and write a helpfull message. This one will be deleted. */ - public JMSAMQException(AMQException s) + public JMSAMQException(AMQException cause) { - super(s.getMessage(), String.valueOf(s.getErrorCode())); - setLinkedException(s); + super(cause.getMessage(), String.valueOf(cause.getErrorCode())); + setLinkedException(cause); + initCause(cause); } } diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java index 535b55ced5..3846ee043d 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java @@ -102,6 +102,7 @@ public abstract class AbstractBytesMessage extends AbstractJMSMessage { JMSException jmse = new JMSException(e.toString()); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java index f0fc394b0b..85818dcd2b 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesTypedMessage.java @@ -490,9 +490,10 @@ public abstract class AbstractBytesTypedMessage extends AbstractBytesMessage } catch (CharacterCodingException e) { - JMSException je = new JMSException("Error decoding byte stream as a UTF8 string: " + e); - je.setLinkedException(e); - throw je; + JMSException jmse = new JMSException("Error decoding byte stream as a UTF8 string: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } @@ -705,9 +706,10 @@ public abstract class AbstractBytesTypedMessage extends AbstractBytesMessage } catch (CharacterCodingException e) { - JMSException ex = new JMSException("Unable to encode string: " + e); - ex.setLinkedException(e); - throw ex; + JMSException jmse = new JMSException("Unable to encode string: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } } diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java index 8681dae2bd..b87275a9ce 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessage.java @@ -187,9 +187,10 @@ public class JMSBytesMessage extends AbstractBytesMessage implements BytesMessag } catch (CharacterCodingException e) { - JMSException je = new JMSException("Error decoding byte stream as a UTF8 string: " + e); - je.setLinkedException(e); - throw je; + JMSException jmse = new JMSException("Error decoding byte stream as a UTF8 string: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } @@ -308,9 +309,10 @@ public class JMSBytesMessage extends AbstractBytesMessage implements BytesMessag } catch (CharacterCodingException e) { - JMSException ex = new JMSException("Unable to encode string: " + e); - ex.setLinkedException(e); - throw ex; + JMSException jmse = new JMSException("Unable to encode string: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java index 6215652c80..cac465e533 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java @@ -402,6 +402,7 @@ public final class JMSHeaderAdapter { MessageFormatException mfe = new MessageFormatException("Only primatives are allowed object is:" + object.getClass()); mfe.setLinkedException(aice); + mfe.initCause(aice); throw mfe; } } diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java index 56e9a5dc73..637d9dd692 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java @@ -119,6 +119,7 @@ public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessag { MessageFormatException mfe = new MessageFormatException("Message not serializable: " + e); mfe.setLinkedException(e); + mfe.initCause(e); throw mfe; } @@ -143,12 +144,14 @@ public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessag { MessageFormatException mfe = new MessageFormatException("Could not deserialize message: " + e); mfe.setLinkedException(e); + mfe.initCause(e); throw mfe; } catch (ClassNotFoundException e) { MessageFormatException mfe = new MessageFormatException("Could not deserialize message: " + e); mfe.setLinkedException(e); + mfe.initCause(e); throw mfe; } finally diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java index f83ae6ace0..fc2006a119 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSTextMessage.java @@ -116,6 +116,7 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text // should never occur JMSException jmse = new JMSException("Unable to decode text data"); jmse.setLinkedException(e); + jmse.initCause(e); throw jmse; } } @@ -146,9 +147,10 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text } catch (CharacterCodingException e) { - JMSException je = new JMSException("Could not decode string data: " + e); - je.setLinkedException(e); - throw je; + JMSException jmse = new JMSException("Could not decode string data: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } else @@ -159,9 +161,10 @@ public class JMSTextMessage extends AbstractJMSMessage implements javax.jms.Text } catch (CharacterCodingException e) { - JMSException je = new JMSException("Could not decode string data: " + e); - je.setLinkedException(e); - throw je; + JMSException jmse = new JMSException("Could not decode string data: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } return _decodedValue; diff --git a/java/client/src/old_test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java b/java/client/src/old_test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java index 44285efd96..1c86aea56c 100644 --- a/java/client/src/old_test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java +++ b/java/client/src/old_test/java/org/apache/qpid/config/JBossConnectionFactoryInitialiser.java @@ -63,11 +63,17 @@ public class JBossConnectionFactoryInitialiser implements ConnectionFactoryIniti } catch (NamingException e) { - throw new JMSException("Unable to lookup object: " + e); + JMSException jmse = new JMSException("Unable to lookup object: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } catch (Exception e) { - throw new JMSException("Error creating topic: " + e); + JMSException jmse = new JMSException("Error creating topic: " + e); + jmse.setLinkedException(e); + jmse.initCause(e); + throw jmse; } } |