Author: ritchiem
Date: Thu Nov 6 04:21:37 2008
New Revision: 711848
URL: http://svn.apache.org/viewvc?rev=711848&view=rev
Log:
QPID-1434 : Changed rethrow() name based on feedback from Rob
Modified:
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
Modified:
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=711848&r1=711847&r2=711848&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
(original)
+++
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
Thu Nov 6 04:21:37 2008
@@ -673,7 +673,7 @@
{
AMQException amqe = (AMQException) e;
- amqe.rethrow();
+ throw amqe.cloneForCurrentThread();
}
else
{
Modified:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java?rev=711848&r1=711847&r2=711848&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
Thu Nov 6 04:21:37 2008
@@ -98,10 +98,9 @@
* {AMQConstant.class, String.class, Throwable.class}
*
* Individual subclasses may override as requried to create a new instance.
- *
- * @throws AMQException
+ *
*/
- public void rethrow() throws AMQException
+ public AMQException cloneForCurrentThread()
{
Class amqeClass = this.getClass();
Class<?>[] paramClasses = {AMQConstant.class, String.class,
Throwable.class};
@@ -118,6 +117,6 @@
newAMQE = new AMQException(getErrorCode(), getMessage(), this);
}
- throw newAMQE;
+ return newAMQE;
}
}
Modified:
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java?rev=711848&r1=711847&r2=711848&view=diff
==============================================================================
---
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
(original)
+++
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/AMQExceptionTest.java
Thu Nov 6 04:21:37 2008
@@ -42,14 +42,10 @@
{
AMQException test = new AMQException(AMQConstant.ACCESS_REFUSED,
"refused", new RuntimeException());
- try
- {
- reThrowException(test);
- }
- catch (AMQException e)
- {
- assertEquals("Exception not of correct class", AMQException.class,
e.getClass());
- }
+ AMQException e = reThrowException(test);
+
+ assertEquals("Exception not of correct class", AMQException.class,
e.getClass());
+
}
/**
@@ -60,14 +56,9 @@
AMQFrameDecodingException test = new
AMQFrameDecodingException(AMQConstant.INTERNAL_ERROR,
"Error",
new
Exception());
- try
- {
- reThrowException(test);
- }
- catch (AMQException e)
- {
- assertEquals("Exception not of correct class",
AMQFrameDecodingException.class, e.getClass());
- }
+ AMQException e = reThrowException(test);
+
+ assertEquals("Exception not of correct class",
AMQFrameDecodingException.class, e.getClass());
}
/**
@@ -77,14 +68,10 @@
public void testRethrowAMQESubclassNoConstructor()
{
AMQExceptionSubclass test = new AMQExceptionSubclass("Invalid Argument
Exception");
- try
- {
- reThrowException(test);
- }
- catch (AMQException e)
- {
- assertEquals("Exception not of correct class", AMQException.class,
e.getClass());
- }
+
+ AMQException e = reThrowException(test);
+
+ assertEquals("Exception not of correct class", AMQException.class,
e.getClass());
}
/**
@@ -92,25 +79,16 @@
* @param test Exception to rethrow
* @throws AMQException the rethrown exception
*/
- private void reThrowException(AMQException test) throws AMQException
+ private AMQException reThrowException(AMQException test)
{
- try
- {
- test.rethrow();
- }
- catch (AMQException amqe)
- {
- assertEquals("Error code does not match.", test.getErrorCode(),
amqe.getErrorCode());
- assertTrue("Exception message does not start as expected.",
amqe.getMessage().startsWith(test.getMessage()));
- assertEquals("Test Exception is not set as the cause", test,
amqe.getCause());
- assertEquals("Cause is not correct", test.getCause(),
amqe.getCause().getCause());
- throw amqe;
- }
- catch (Throwable e)
- {
- fail("Throwable recieved when AMQException expected:" + e);
- }
+ AMQException amqe = test.cloneForCurrentThread();
+
+ assertEquals("Error code does not match.", test.getErrorCode(),
amqe.getErrorCode());
+ assertTrue("Exception message does not start as expected.",
amqe.getMessage().startsWith(test.getMessage()));
+ assertEquals("Test Exception is not set as the cause", test,
amqe.getCause());
+ assertEquals("Cause is not correct", test.getCause(),
amqe.getCause().getCause());
+ return amqe;
}
/**